VB.net VB faire appel a une fonction et ne pas attendre le retour

cs_JuVeNaL Messages postés 8 Date d'inscription mardi 8 mars 2005 Statut Membre Dernière intervention 27 février 2012 - 2 févr. 2012 à 14:27
ucfoutu Messages postés 18038 Date d'inscription lundi 7 décembre 2009 Statut Modérateur Dernière intervention 11 avril 2018 - 7 févr. 2012 à 00:15
Bonjour,

Je suis débutant et j'ai su crée un service qui consulte une DB (mysql) cette DB comprendre 10 enregistrements
et je souhaite faire un sorte que le traitement s’exécute le plus vite possible.
Actuellement je fait appel a une fonction qui traite une par un les enregistrement mais ma fonction me libère que quand il a fini un traitement pour commencer un autre , comment puis-je faire pour qu'il lance la fonction et n'attend pas pour lancer la suivante ?

Bien à vous
JuVeNaL

13 réponses

NSUADI Messages postés 540 Date d'inscription mardi 4 août 2009 Statut Membre Dernière intervention 1 février 2013 2
2 févr. 2012 à 14:49
Salut,

ta requête me semble pas très claire,tu peux être plus claire,stp?
Qu'est ce que t'entends par traitement?


Ce qui compte,ce n'est pas ce qu'on a mais plutôt ce que l'on fait avec ce qu'on a...

Visual Basic .Net is the best
and vb6.0
0
cs_JuVeNaL Messages postés 8 Date d'inscription mardi 8 mars 2005 Statut Membre Dernière intervention 27 février 2012
2 févr. 2012 à 14:57
J'ai crée un service Windows , le service tourne sur un serveur et consulte une DB mysql
la DB mysql est alimenté manuellement par mes soins et j'ajoute des entrées dedans

Le service Windows consulte la DB et regarde le nombre d'enregistrement et je fait un boucle la dessus
ou je fait appel a une fonction que j'ai crée avec comme argument le résultat de ma table

Fonction (table(i)) i= nombres d'enregistrement dans ma DB ( 1, 2, 3, 4, 5)


Mais le problème c'est qu'il attend d'avoir traiter le 1 avant de passer au deuxième ..
est-ce qu'il existe une possibilité pour ne pas attendre et directement passer a la requête N° 2, 3, 4, 5 etc ....

Bien à vous
JuVeNaL
0
NHenry Messages postés 15117 Date d'inscription vendredi 14 mars 2003 Statut Modérateur Dernière intervention 10 mai 2024 159
2 févr. 2012 à 19:38
Bonjour,

Intéresses-toi aux threads : System.Threading.Thread ou aussi aux BackgroundWorker.

---------------------------------------------------------------------
[list=ordered][*]Pour poser correctement une question et optimiser vos chances d'obtenir des réponses, pensez à lire le règlement CS, ce lien ou encore celui-ci[*]Quand vous postez un code, merci d'utiliser la coloration syntaxique (3ième icône en partant de la droite : )
[*]Si votre problème est résolu (et uniquement si c'est le cas), pensez à mettre "Réponse acceptée" sur le ou les messages qui vous ont aidés./list
---
Mon site
0
cs_JuVeNaL Messages postés 8 Date d'inscription mardi 8 mars 2005 Statut Membre Dernière intervention 27 février 2012
3 févr. 2012 à 08:56
Bonjour NHenry,
Voici le morceau du code qui me lance ma fonction "test" avec un timer tout fonctione ..
Maintenant j'ai regarder le BackgroundWorker et c'est exactement ce que je cherche .. maintenant je ne vois pas trop comment l'intégrer a mon code suivant :

Protected Overrides Sub OnStart(ByVal args() As String)
SQLConnection.ConnectionString = ServerString
Dim autoEvent As New AutoResetEvent(False)
Dim timerDelegate As TimerCallback = AddressOf test
Timer1 = New Timer(timerDelegate, autoEvent, 0, TimerDelay)
End Sub

J'ai déja ajouté le contrôle Backgroundworker

Pouvez-vous m'aider ?

Bien à vous
JuVeNaL
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
NHenry Messages postés 15117 Date d'inscription vendredi 14 mars 2003 Statut Modérateur Dernière intervention 10 mai 2024 159
4 févr. 2012 à 01:03
Bonjour,

Je pense que cette page te donnera les bases du fonctionnement.

---------------------------------------------------------------------
[list=ordered][*]Pour poser correctement une question et optimiser vos chances d'obtenir des réponses, pensez à lire le règlement CS, ce lien ou encore celui-ci[*]Quand vous postez un code, merci d'utiliser la coloration syntaxique (3ième icône en partant de la droite : )
[*]Si votre problème est résolu (et uniquement si c'est le cas), pensez à mettre "Réponse acceptée" sur le ou les messages qui vous ont aidés./list
---
Mon site
0
kobeymane Messages postés 58 Date d'inscription dimanche 29 janvier 2012 Statut Membre Dernière intervention 29 avril 2012
5 févr. 2012 à 01:43
Bonjour,
Je suis un débutant en vb.net. Je veux élaborer un programme qui calcul l'integrale d'une fonction saisie par l'utilisateur (dans le cadre d'un PFE). Le problème c'est au niveau de la saisie de la fonction: L'utilisateur doit taper une fonction f(x) donc de type string, et lors du calcul j'ai besoin de f(x+h) et f(x) en Decimal. La conversion ne se fait pas.
Voici comment mon programme se présente:

Public Class Form1
Private Sub form1_load()
TextBox1.Text = "" 'f(x)
TextBox2.Text = "" 'a
TextBox3.Text = "" 'b
Label4.Text = "" 'resultat
End Sub


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim inf, sup As Integer
Dim a, b, aire As Decimal
Dim fn As String
Dim n As Integer = 1000000
Dim x, h, i, j As Decimal
aire = 0
x = a

'saisie de la fonction
fn = TextBox1.Text
fn = LCase(fn)
If fn = "" Then
MsgBox("vous devez entrer une fonction au clavier")
Exit Sub
End If

'saisie des bornes: entrer des valeurs numériques
If Not (IsNumeric(TextBox2.Text)) Then
MsgBox("entrer une valeur numérique de la borne inférieure")
Exit Sub

End If

If Not (IsNumeric(TextBox3.Text)) Then
MsgBox("entrer une valeur numérique de la borne supérieure")
Exit Sub

End If

'convertir les texts

inf = CType(TextBox2.Text, Integer) 'a
sup = CType(TextBox3.Text, Integer) 'b
If inf > sup Then
h = inf
inf = sup
sup = h
End If

'calcul de l'integral et affichage du résultat
h = (sup - inf) / n
For x = inf To sup
i = CType(fn + h, Integer)
j = CType(fn, Decimal)
aire = aire + h * (i + j) / 2
x = x + h
Next x
Label4.Text = Math.Round(aire, 2).ToString
End Sub
End Class





Est-il un moyen de corriger le problème? Sinon quelle est la solution?
0
NHenry Messages postés 15117 Date d'inscription vendredi 14 mars 2003 Statut Modérateur Dernière intervention 10 mai 2024 159
5 févr. 2012 à 01:51
Bonjour,

Il te faut faire en sorte de faire une fonction qu prend en paramètre les informations et retourne le résultat, sansqu'elle interagisse directement avec les controles de la form.

Quand tu postes un code regardes le point 2 de ma signature.

Genre :
Sub UseFonction()
Dim Prm1 as integer, Prm2 as Integer, Resultat as Integer

if not Integer.TryParse(TextBox1.Text,Prm1) Then
 'Pas bon
End If

...

Resultat=MaFonction(Prm1,Prm2)

...
End Sub


A toi d'adapter et de t'inspirer de cet exemple.

---------------------------------------------------------------------
[list=ordered][*]Pour poser correctement une question et optimiser vos chances d'obtenir des réponses, pensez à lire le règlement CS, ce lien ou encore celui-ci[*]Quand vous postez un code, merci d'utiliser la coloration syntaxique (3ième icône en partant de la droite : )
[*]Si votre problème est résolu (et uniquement si c'est le cas), pensez à mettre "Réponse acceptée" sur le ou les messages qui vous ont aidés./list
---
Mon site
0
kobeymane Messages postés 58 Date d'inscription dimanche 29 janvier 2012 Statut Membre Dernière intervention 29 avril 2012
6 févr. 2012 à 02:15
Bonjour,
Merci M. NHenry pour votre aide mais je veux juste une chose:
Immaginez que je vous demande de réaliser un programme qui permet de saisir une fonction: c'est à dire que l'utilisateur tape une fontion f(x) au clavier puis ce programme me donne l'accès à cette fonction pour la manipuler: calculer f(x+h) 'avec h donné'. C'est le seul problème qui me bloque.



J'ai trouvé le code du calcul integrale réalisé par un éleve ingénieur, mais je l'ai trouvé plus avancé que mon niveau:
comme vous venez de dire, il a crée une fonction nomée integrale qui fait le calcul et à l'interieur il a appelé une autre fonction très longue appelée distributeur (que j'en ai rien compris) qui fait le traitement de f(x+h) je pense...

voici le code de la fonction integrale:
Function integrale(ByVal a As Double, ByVal b As Double) As Double
        Dim ok As Boolean, h, u0, v0, v1, q As Double
        fonction = TextBox18.Text
        fonction = LCase(fonction)
        k = 1
        t = 1
        e1 = 0
        e2 = 1
        S = 0

        ok = True
        If a > b Then
            h = a
            a = b
            b = h
            ok = False
        End If


        If a = b Then
            q = 0
            Return q
            Exit Function
        End If
        

        u0 = a
        S = 0

        distributeur(u0, 1, 1, 1)

        v0 = S
        S = 0
        h = 0.01
        'h = PI / 10

        Do While u0 <= b
            'distributeur(u0 + h, 1, 1, 1)
            'v1 = S
            distributeur(u0 + h / 2, 1, 1, 1)
            v1 = S
            'q += (h / 2) * (v0 + v1)
            q += h * v1
            'v0 = v1
            S = 0
            u0 += h
        Loop


        If ok = True Then
            Return q
        Else
            Return -q
        End If
        q = 0


    End Function



et le code de la fonction distributeur:
Sub distributeur(ByVal a As Object, ByVal i As Integer, ByVal t As Integer, ByVal e As Integer)
        Dim n As Integer
        If fonction = "" Then
            MsgBox("vous devez entrer une fonction au clavier")
            Exit Sub
        End If
        If Mid(fonction, 1, 1) = "-" Then
            If i = 1 Then
                i = 2
            End If
        End If
        If i > 1 Then
            If Mid(fonction, i - 1, 1) = "(" Then
                If Mid(fonction, i, 1) = "-" Then
                    i += 1
                End If
            End If
        End If
        If Mid(fonction, i, 1) = ")" Then
            'MsgBox(k)
            If k > 0 Then
                If Mid(fonction, k, 1) = "-" Then
                    k = -1
                Else
                    k = 1
                End If
            Else
                'MsgBox(k + 1)
                k = 1
            End If
            '  If i <> 1 Then
            ' If Mid(fonction, i - 1, 1) <> "(" Then

            If e = 2 Then
                'fractiontrigo()
                If z = 0 Then
                    If e1 = 1 Then
                        'MsgBox("ouais2")
                        S3 = Sin(S)
                        If S3 = 0 Then
                            S3 = 0.0001
                        End If
                        S = S0 + k * (S2 / S3)
                        Label2.Text = S
                    Else
                        'S = 0
                        S1 = k * Sin(S)
                        'MsgBox(S1)
                        S = S0 + S1
                        Label2.Text = S
                        S0 = 0
                        e = e0
                        z = z0
                    End If
                Else
                    S1 = k * z * Sin(S)
                    ' S = 0
                    S = S0 + S1
                    Label2.Text = S
                    'z = 0
                    S0 = 0
                    e = e0
                    z = z0
                End If
            ElseIf e = 3 Then
                'fractiontrigo()
                If z = 0 Then
                    If e1 = 1 Then
                        S3 = Cos(S)
                        If S3 = 0 Then
                            S3 = 0.0001
                        End If
                        S = S0 + k * (S2 / S3)
                        Label2.Text = S
                        'MsgBox("ok")
                    Else
                        'S = 0
                        S1 = k * Cos(S)
                        S = S0 + S1
                        Label2.Text = S
                        S0 = 0
                        e = e0
                        z = z0
                    End If
                Else
                    S1 = k * z * Cos(S)
                    ' S = 0
                    S = S0 + S1
                    Label2.Text = S
                    S0 = 0
                    e = e0
                    z = z0
                End If
            ElseIf e = 4 Then
                'fractiontrigo()
                If z = 0 Then
                    If e1 = 1 Then
                        S3 = Exp(S)
                        If S3 = 0 Then
                            S3 = 0.00001
                        End If
                        S = S0 + k * (S2 / S3)
                        Label2.Text = S
                        'MsgBox("ok")
                    Else
                        S1 = k * Exp(S)
                        'S = 0
                        S = S0 + S1
                        Label2.Text = S
                        S0 = 0
                        e = e0
                        z = z0
                    End If
                Else
                    S1 = k * z * Exp(S)
                    ' S = 0
                    S = S0 + S1
                    Label2.Text = S
                    S0 = 0
                    e = e0
                    z = z0
                End If

            ElseIf e = 5 Then
                'fractiontrigo()
                If z = 0 Then
                    If e1 = 1 Then
                        If S = 0 Then
                            S3 = -20
                        ElseIf S > 0 Then
                            S3 = Log(S)
                        End If
                        If S3 = 0 Then
                            S3 = 0.0001
                        End If
                        S = S0 + k * (S2 / S3)
                        Label2.Text = S
                        'MsgBox("ok")
                    Else
                        If S = 0 Then
                            S1 = -20 * k
                        ElseIf S > 0 Then
                            S1 = k * Log(S)
                        End If
                        ' S1 = k * Log(S)
                        'S = 0
                        S = S0 + S1
                        Label2.Text = S
                        S0 = 0
                        e = e0
                        z = z0
                    End If
                Else
                    If S = 0 Then
                        S1 = -20 * k * z
                    ElseIf S > 0 Then
                        S1 = k * z * Log(S)
                    End If
                    'S1 = k * z * Log(S)
                    ' S = 0
                    S = S0 + S1
                    Label2.Text = S
                    S0 = 0
                    e = e0
                    z = z0
                End If
            ElseIf e = 10 Then
                'fractiontrigo()
                If z = 0 Then
                    If e1 = 1 Then
                        S3 = th(S)
                        If S3 = 0 Then
                            S3 = 0.0001
                        End If
                        S = S0 + k * (S2 / S3)
                        Label2.Text = S
                        'MsgBox("ok")
                    Else
                        S1 = k * th(S)
                        'S = 0
                        S = S0 + S1
                        Label2.Text = S
                        S0 = 0
                        e = e0
                        z = z0
                    End If
                Else
                    S1 = k * z * th(S)
                    ' S = 0
                    S = S0 + S1
                    Label2.Text = S
                    S0 = 0
                    e = e0
                    z = z0
                End If

            ElseIf e = 11 Then
                'fractiontrigo()
                If z = 0 Then
                    If e1 = 1 Then
                        S3 = sh(S)
                        If S3 = 0 Then
                            S3 = 0.0001
                        End If
                        S = S0 + k * (S2 / S3)
                        Label2.Text = S
                        'MsgBox("ok")
                    Else
                        S1 = k * sh(S)
                        'S = 0
                        S = S0 + S1
                        Label2.Text = S
                        S0 = 0
                        e = e0
                        z = z0
                    End If
                Else
                    S1 = k * z * sh(S)
                    ' S = 0
                    S = S0 + S1
                    Label2.Text = S
                    S0 = 0
                    e = e0
                    z = z0
                End If

            ElseIf e = 12 Then
                'fractiontrigo()
                If z = 0 Then
                    If e1 = 1 Then
                        S3 = ch(S)
                        If S3 = 0 Then
                            S3 = 0.0001
                        End If
                        S = S0 + k * (S2 / S3)
                        Label2.Text = S
                        'MsgBox("ok")
                    Else
                        S1 = k * ch(S)
                        'S = 0
                        S = S0 + S1
                        Label2.Text = S
                        S0 = 0
                        e = e0
                        z = z0
                    End If
                Else
                    S1 = k * z * ch(S)
                    ' S = 0
                    S = S0 + S1
                    Label2.Text = S
                    S0 = 0
                    e = e0
                    z = z0
                End If

            ElseIf e = 6 Then
                'fractiontrigo()
                If z = 0 Then
                    If e1 = 1 Then
                        S3 = Tan(S)
                        If S3 = 0 Then
                            S3 = 0.0001
                        End If
                        S = S0 + k * (S2 / S3)
                        Label2.Text = S
                        'MsgBox("ok")
                    Else
                        S1 = k * Tan(S)
                        'S = 0
                        S = S0 + S1
                        Label2.Text = S
                        S0 = 0
                        e = e0
                        z = z0
                    End If
                Else
                    S1 = k * z * Tan(S)
                    ' S = 0
                    S = S0 + S1
                    Label2.Text = S
                    S0 = 0
                    e = e0
                    z = z0
                End If
            ElseIf e = 7 Then
                'fractiontrigo()
                If z = 0 Then
                    If e1 = 1 Then
                        If S >= 0 Then
                            S3 = Sqrt(S)
                        Else : S3 = 0
                        End If
                        If S3 = 0 Then
                            S3 = 0.0001
                        End If
                        S = S0 + k * (S2 / S3)
                        Label2.Text = S

                        'MsgBox("ok")
                    Else
                        If S >= 0 Then
                            S1 = k * Sqrt(S)
                        Else : S1 = 0
                        End If
                        'S = 0
                        S = S0 + S1
                        Label2.Text = S
                        S0 = 0
                        e = e0
                        z = z0
                    End If
                Else
                    If S >= 0 Then
                        S1 = k * z * Sqrt(S)
                    Else : S1 = 0
                    End If
                    ' S = 0
                    S = S0 + S1
                    Label2.Text = S
                    S0 = 0
                    e = e0
                    z = z0
                End If
            ElseIf e = 8 Then
                If z = 0 Then
                    If S3 = 0 Then
                        S3 = 0.0001
                    End If
                    S1 = k * (S2 / S3)
                    'S = 0

                    S = S0 + S1 + s4
                    Label2.Text = S
                    S0 = 0
                    e = e0
                    z = z0
                Else
                    If S3 = 0 Then
                        S3 = 0.0000001
                    End If
                    S1 = k * z * (S2 / S3)
                    ' S = 0
                    S = S0 + S1 + s4
                    Label2.Text = S
                    S0 = 0
                    e = e0
                    z = z0
                End If

            ElseIf e = 9 Then
                'fractiontrigo()
                If z = 0 Then
                    If e1 = 1 Then
                        'MsgBox("ouais2")
                        S3 = Abs(S)
                        If S3 = 0 Then
                            S3 = 0.0001
                        End If
                        S = S0 + k * (S2 / S3)
                        Label2.Text = S
                        e = e0
                    Else
                        'S = 0
                        S1 = k * Abs(S)
                        S = S0 + S1
                        Label2.Text = S
                        S0 = 0
                        e = e0
                        z = z0
                    End If
                Else
                    S1 = k * z * Abs(S)
                    ' S = 0
                    S = S0 + S1
                    Label2.Text = S
                    'z = 0
                    S0 = 0
                    e = e0
                    z = z0
                End If
            End If

            If Mid(fonction, i + 1, 1) = ")" Then
                'MsgBox("ok")
                If Mid(fonction, e2, 1) = "/" Then
                    S3 = S
                    If z = 0 Then
                        If S3 = 0 Then
                            S3 = 0.0001
                        End If
                        S = k * (S2 / S3)
                        S = S0 + s4 + S
                        's4 = S
                        Label2.Text = S
                        s4 = 0
                        z = z0
                        distributeur(a, i + 2, t, e)
                        Exit Sub
                    Else
                        If S3 = 0 Then
                            S3 = 0.0001
                        End If
                        S = k * z * (S2 / S3)
                        S = S0 + s4 + S
                        's4 = S
                        Label2.Text = S
                        s4 = 0
                        z = z0
                        distributeur(a, i + 2, t, e)
                        Exit Sub
                    End If
                Else
                    distributeur(a, i + 1, t, e)
                    Exit Sub
                End If
            ElseIf Mid(fonction, i + 1, 1) = "/" Then
                e2 = i + 1
                'e1 = 1
                S2 = S
                i += 2
                S = 0
                distributeur(a, i, t, e)
                Exit Sub
            Else
                i += 2
                e2 = 1
            End If
            k = 0
            'distributeur(a, i, t, e)
        End If
        'End If
        'End If

        If Mid(fonction, i, 1) = "x" Then
            polynome(a, i, 1, 1, e)
            Exit Sub
        End If
        If Mid(fonction, i, 1) = "s" Then
            If Mid(fonction, i + 1, 1) = "i" Then
                test(i)
                e0 = e
                k = i - 1
                S0 = S
                S = 0
                sinus(a, i, 1, 1)
                Exit Sub
            ElseIf Mid(fonction, i + 1, 1) = "h" Then
                test(i)
                e0 = e
                k = i - 1
                S0 = S
                S = 0
                sinh(a, i, 1, 1)
                Exit Sub
            End If
        End If
        If Mid(fonction, i, 1) = "c" Then
            If Mid(fonction, i + 1, 1) = "o" Then
                test(i)
                e0 = e
                k = i - 1
                S0 = S
                S = 0
                cosinus(a, i, 1, 1)
                Exit Sub
            ElseIf Mid(fonction, i + 1, 1) = "h" Then
                test(i)
                e0 = e
                k = i - 1
                S0 = S
                S = 0
                cosh(a, i, 1, 1)
                Exit Sub
            End If
        End If
        If Mid(fonction, i, 1) = "e" Then
            test(i)
            e0 = e
            k = i - 1
            S0 = S
            S = 0
            exponentielle(a, i, 1, 1)
            Exit Sub
        End If
        If Mid(fonction, i, 1) = "l" Then
            test(i)
            e0 = e
            k = i - 1
            S0 = S
            S = 0
            logarithme(a, i, 1, 1)
            Exit Sub
        End If
        If Mid(fonction, i, 1) = "t" Then
            If Mid(fonction, i + 1, 1) = "h" Then
                test(i)
                e0 = e
                k = i - 1
                S0 = S
                S = 0
                tanh(a, i, 1, 1)
                Exit Sub
                'End If
                ' End If
            ElseIf Mid(fonction, i + 1, 1) = "a" Then
                test(i)
                e0 = e
                k = i - 1
                S0 = S
                S = 0
                tangente(a, i, 1, 1)
                Exit Sub
            End If
        End If
        If Mid(fonction, i, 1) = "r" Then
            test(i)
            e0 = e
            k = i - 1
            S0 = S
            S = 0
            racine(a, i, 1, 1)
            Exit Sub
        End If
        If Mid(fonction, i, 1) = "f" Then
            test(i)
            e0 = e
            k = i - 1
            s4 = S
            S0 = S
            S = 0
            S0 = 0
            fraction(a, i, 1, 1)
            Exit Sub
        End If
        If Mid(fonction, i, 1) = "a" Then
            test(i)
            e0 = e
            k = i - 1
            S0 = S
            S = 0
            valeur_absolue(a, i, 1, 1)
            Exit Sub
        End If
        For n = 0 To 9
            If Val(Mid(fonction, i, 1)) = n Then
                If i = 1 Then
                    b = 1
                ElseIf i <> 1 Then
                    If Mid(fonction, i - 1, 1) = "+" Then
                        b = 1
                    ElseIf Mid(fonction, i - 1, 1) = "-" Then
                        b = -1
                    ElseIf Mid(fonction, i - 1, 1) = "" Then
                        b = 1
                    ElseIf Mid(fonction, i - 1, 1) = "(" Then
                        b = 1
                    End If
                End If
                For j = i To Len(fonction)
                    If Mid(fonction, j, 1) = "*" Then
                        If Mid(fonction, j + 1, 1) = "x" Then
                            t = Val(Mid(fonction, i, j - i))
                            i = j + 1
                            polynome(a, i, t, b, e)
                            Exit Sub

                        ElseIf Mid(fonction, j + 1, 1) = "s" Then
                            If Mid(fonction, j + 2, 1) = "i" Then
                                If i > 1 Then
                                    k = i - 1
                                Else
                                    k = 0
                                End If
                                z = Val(Mid(fonction, i, j - i))
                                i = j + 1
                                S0 = S
                                S = 0
                                sinus(a, i, t, b)
                                Exit Sub
                            ElseIf Mid(fonction, j + 2, 1) = "h" Then
                                If i > 1 Then
                                    k = i - 1
                                Else
                                    k = 0
                                End If
                                z = Val(Mid(fonction, i, j - i))
                                i = j + 1
                                S0 = S
                                S = 0
                                sinh(a, i, t, b)
                                Exit Sub
                            End If
                        ElseIf Mid(fonction, j + 1, 1) = "c" Then
                            If Mid(fonction, j + 2, 1) = "o" Then
                                If i > 1 Then
                                    k = i - 1
                                Else
                                    k = 0
                                End If
                                z = Val(Mid(fonction, i, j - i))
                                i = j + 1
                                S0 = S
                                S = 0
                                cosinus(a, i, t, b)
                                Exit Sub
                            ElseIf Mid(fonction, j + 2, 1) = "h" Then
                                If i > 1 Then
                                    k = i - 1
                                Else
                                    k = 0
                                End If
                                z = Val(Mid(fonction, i, j - i))
                                i = j + 1
                                S0 = S
                                S = 0
                                cosh(a, i, t, b)
                                Exit Sub
                            End If
                        ElseIf Mid(fonction, j + 1, 1) = "e" Then
                            If i > 1 Then
                                k = i - 1
                            Else
                                k = 0
                            End If
                            z = Val(Mid(fonction, i, j - i))
                            i = j + 1
                            S0 = S
                            S = 0
                            exponentielle(a, i, t, b)
                            Exit Sub
                        ElseIf Mid(fonction, j + 1, 1) = "l" Then
                            If i > 1 Then
                                k = i - 1
                            Else
                                k = 0
                            End If
                            z = Val(Mid(fonction, i, j - i))
                            i = j + 1
                            S0 = S
                            S = 0
                            logarithme(a, i, t, b)
                            Exit Sub
                        ElseIf Mid(fonction, j + 1, 1) = "t" Then
                            If Mid(fonction, j + 2, 1) = "a" Then
                                If i > 1 Then
                                    k = i - 1
                                Else
                                    k = 0
                                End If
                                z = Val(Mid(fonction, i, j - i))
                                i = j + 1
                                S0 = S
                                S = 0
                                tangente(a, i, t, b)
                                Exit Sub
                            ElseIf Mid(fonction, j + 2, 1) = "h" Then
                                If i > 1 Then
                                    k = i - 1
                                Else
                                    k = 0
                                End If
                                z = Val(Mid(fonction, i, j - i))
                                i = j + 1
                                S0 = S
                                S = 0
                                tanh(a, i, t, b)
                                Exit Sub
                            End If
                        ElseIf Mid(fonction, j + 1, 1) = "r" Then
                            If i > 1 Then
                                k = i - 1
                            Else
                                k = 0
                            End If
                            z = Val(Mid(fonction, i, j - i))
                            i = j + 1
                            S0 = S
                            S = 0
                            racine(a, i, t, b)
                            Exit Sub
                        ElseIf Mid(fonction, j + 1, 1) = "f" Then
                            If i > 1 Then
                                k = i - 1
                            Else
                                k = 0
                            End If
                            z = Val(Mid(fonction, i, j - i))
                            i = j + 1
                            S0 = S
                            S = 0
                            fraction(a, i, t, b)
                            Exit Sub
                        ElseIf Mid(fonction, j + 1, 1) = "a" Then
                            If i > 1 Then
                                k = i - 1
                            Else
                                k = 0
                            End If
                            z = Val(Mid(fonction, i, j - i))
                            i = j + 1
                            S0 = S
                            S = 0
                            valeur_absolue(a, i, t, b)
                            Exit Sub
                        End If
                    End If

                    If Mid(fonction, j, 1) = "+" Then
                        t = Val(Mid(fonction, i, j - i))
                        i = j + 1
                        ' i = i + j
                        S = S + b * t
                        Label2.Text = S
                        distributeur(a, i, t, e)
                        Exit Sub

                    End If
                    If Mid(fonction, j, 1) = "/" Then
                        e2 = j
                        t = Val(Mid(fonction, i, j - i))
                        i = j + 1
                        ' i = i + j
                        S = S + b * t
                        S2 = S
                        'e1 = 1
                        Label2.Text = S
                        S = 0
                        distributeur(a, i, t, e)
                        Exit Sub

                    End If
                    If Mid(fonction, j, 1) = "-" Then
                        t = Val(Mid(fonction, i, j - i))
                        i = j + 1
                        'i = i + j
                        S = S + b * t
                        distributeur(a, i, t, e)
                        Exit Sub

                    End If
                    If Mid(fonction, j, 1) = ")" Then
                        t = Val(Mid(fonction, i, j - i))
                        i = j
                        'i = i + j
                        S = S + b * t
                        S3 = S
                        'S += s4
                        distributeur(a, i, t, e)
                        Exit Sub
                    End If
                    If Mid(fonction, j + 1, 1) = "" Then
                        t = Val(Mid(fonction, i, j - i + 1))
                        If InStr("+", fonction) 0 Or InStr("-", fonction) 0 Or InStr("*", fonction) = 0 Or InStr("/", fonction) = 0 Then
                            'If Mid(fonction, 1, 1) = "-" Then
                            'S = -t
                            'End If
                            'Else

                            S += b * t
                            Label2.Text = S

                            Exit Sub
                        End If
                        'If Mid(fonction, j + 1, 1) = "+" Then   'Or "" Then
                        'MsgBox("yes")
                        'p = j
                        'k = j + 1
                        'p = Val(Mid(fonction, i + 2, j - i - 1))
                        ' S = S + b * t * a ^ p
                        'i = j + 2
                        'distributeur(a, i)
                        'Label2.Text = S
                        'End If
                        Exit For
                    End If
                Next j


                'S += e * b * t
                'Label2.Text = S
                ' Exit Sub
                'End If
                If Mid(fonction, i - 1, 1) = "-" Then
                    S = S - t
                    i = j
                    Label2.Text = S
                    'distributeur(a, i)
                End If
                If Mid(fonction, i - 1, 1) = "+" Then
                    S = S + t
                    i = j
                    Label2.Text = S
                    'distributeur(a, i)
                    Exit Sub
                End If

                ' If i = 1 Then
                ' If Mid(fonction, i + 1, 1) = "" Then
                'Label2.Text = Val(TextBox1.Text)
                'End If
                'End If
                ' Next j
            End If
        Next n

    End Sub


Voila!!! Ya-t-il un programme plus simple pour saisir f(x) et traiter f(x) et f(x+h) numériquement ???

Merci pour votre AIDE
0
ucfoutu Messages postés 18038 Date d'inscription lundi 7 décembre 2009 Statut Modérateur Dernière intervention 11 avril 2018 211
6 févr. 2012 à 08:04
ce code est du VB6 et non du VB.Net
et tu as ouvert 4 autres discussions à ce sujet, kobeymane


Maintenant : le code que tu as trouvé (écrit, dis-tu, par un ingénieurs) est celui d'une fonction, d'une part, et d'une procédure, d'autre part.

Il ne traite nullement de la saisie ni de l'interface, dont il n'est cependant pas difficile de deviner quels contrôles elle contient.

En rappelant que c'est dans le cadre de ton PFE.

____________________
Réponse exacte ? => "REPONSE ACCEPTEE" pour faciliter les recherches d'autres forumeurs.
Pas d'aide en ligne installée ? ==> ne comptez pas sur moi pour simplement vous dire ce qu'elle contient
0
ucfoutu Messages postés 18038 Date d'inscription lundi 7 décembre 2009 Statut Modérateur Dernière intervention 11 avril 2018 211
6 févr. 2012 à 08:07
Mais je viens de voir que le ménage a été fait et que 3 de tes quatre autres discussions viennent d'être supprimées.


____________________
Réponse exacte ? => "REPONSE ACCEPTEE" pour faciliter les recherches d'autres forumeurs.
Pas d'aide en ligne installée ? ==> ne comptez pas sur moi pour simplement vous dire ce qu'elle contient
0
kobeymane Messages postés 58 Date d'inscription dimanche 29 janvier 2012 Statut Membre Dernière intervention 29 avril 2012
6 févr. 2012 à 22:59
Bonjour,
Je pose généralment des questions sur d'autres forums mais je n'obtiens pas de réponses c'est pourquoi j'ai faits 4 postes dans des thèmes différents. Je m'exuse si cela dérange les admins.

Peux-je avoir le tout petit programme qui SAISIE f(x) et permet la manipulation numérique pour CALCULER f(x) et f(x+h)? J'ai pas encore eu de réponse .
Merci d'avance
0
ucfoutu Messages postés 18038 Date d'inscription lundi 7 décembre 2009 Statut Modérateur Dernière intervention 11 avril 2018 211
7 févr. 2012 à 00:07
Tu en as eu une (et la seule acceptable) s'agissant d'un exercice dans le cadre de ton PFE
PS : "Siffler" ne sert à rien


____________________
Réponse exacte ? => "REPONSE ACCEPTEE" pour faciliter les recherches d'autres forumeurs.
Pas d'aide en ligne installée ? ==> ne comptez pas sur moi pour simplement vous dire ce qu'elle contient
0
ucfoutu Messages postés 18038 Date d'inscription lundi 7 décembre 2009 Statut Modérateur Dernière intervention 11 avril 2018 211
7 févr. 2012 à 00:15
et je te cite :
Lors de la compilation, un message d'erreur m'informe qu'il est impossible de convertir f(x) en type numérique. J'ai déja un programme que j'ai téléchargé sur le site qui calcul l'integrale mais les algorithmes se different en plus je ne veux pas faire de copier coller dans mon projet

Et c'est pourtant ce que tu cherches à faire d'une certaine manière, pour ne pas dire d'une manière certaine
Travaille et mérite ta note.

____________________
Réponse exacte ? => "REPONSE ACCEPTEE" pour faciliter les recherches d'autres forumeurs.
Pas d'aide en ligne installée ? ==> ne comptez pas sur moi pour simplement vous dire ce qu'elle contient
0
Rejoignez-nous