Erreur If...then...else en VBA

Résolu
Mehdi Ier -  
galijo Messages postés 97 Date d'inscription   Statut Membre Dernière intervention   -
Bonjour!
Je serais curieux de savoir ce qu'il y a de faux dans cette instruction

Cells(i, 3).Value = InputBox("Entrez un compte")
If Cells(i, 3).Value = "0" Then i = i + 1
ElseIf Cells(i, 3).Value = "1" Then Exit Sub
Else: j = 4
End If

Merci!

8 réponses

JSS Messages postés 3745 Date d'inscription   Statut Contributeur Dernière intervention   32
 
les :

Cells(i, 3).Value = InputBox("Entrez un compte")
If Cells(i, 3).Value = "0" Then i = i + 1
ElseIf Cells(i, 3).Value = "1" Then Exit Sub
Else: j = 4
End If

JSS.j'ai.bon.la?
2
Mehdi Ier
 
Bon, ben finalement, j'ai foutu toutes les instructions à la ligne et ça marche, donc merci.
?????????????????????????
2
JSS Messages postés 3745 Date d'inscription   Statut Contributeur Dernière intervention   32
 
bon ben c'est cool si ca marche !

bon courage

a plus

JSS
0
spingo
 
Ben, t'avais raison il suffit de renvoyer à la ligne tt ce qui sui l'instruction Then

Tnx a lot
0

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

Posez votre question
galijo Messages postés 97 Date d'inscription   Statut Membre Dernière intervention   22
 
salut c'est quoi le problème ici quand je débogue il fait quelque fois de fausses opérations


Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim X As Int32 = TextBox1.Text
Dim Y As Int32 = TextBox2.Text

TextBox3.Text = (X + Y)

End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

Dim X As Integer = TextBox1.Text
Dim Y As Integer = TextBox2.Text

TextBox3.Text = (X - Y)
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

Dim X As Integer = TextBox1.Text
Dim Y As Integer = TextBox1.Text

TextBox3.Text = (X * Y)
End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click

Dim X As Integer = TextBox1.Text
Dim Y As Integer = TextBox1.Text

TextBox3.Text = (X / Y)

End Sub

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click

Dim X As Integer = TextBox1.Text
Dim Y As Integer = TextBox1.Text

If TextBox3.Text = (X + Y) Then TextBox3.Text = (X + Y)
If TextBox3.Text = (X - Y) Then TextBox3.Text = (X - Y)
If TextBox3.Text = (X * Y) Then TextBox3.Text = (X * Y)
If TextBox3.Text = (X / Y) Then TextBox3.Text = (X / Y)



End Sub
End Class
0
Mehdi Ier
 
Ben c'est exactement la même chose...?
-1
JSS Messages postés 3745 Date d'inscription   Statut Contributeur Dernière intervention   32
 
il faut enlever les : sur la ligne du else

JSS.j'ai.bon.la?
0
Mehdi Ier
 
Ouais mais ça les met automatiquement dès que je saute une ligne.
-1
Mehdi Ier
 
Il me met comme erreur "Else sans If", va savoir pourquoi!?
-2