Instruction If dans VB 6.0

Fermé
Polly - 14 oct. 2005 à 18:35
Armojax Messages postés 1858 Date d'inscription mercredi 19 janvier 2005 Statut Membre Dernière intervention 22 mars 2024 - 14 oct. 2005 à 18:52
Bonjour,

Pouvez-vous SVP me corriger le code suivant:

Vérifier surtout l'utilisation de Else If et la définition des conditions.

If Rep = "01" Or Rep = "02" Or Rep = "03" Then
VarNum = Varold
operator.Text = Varoperator
ElseIf Rep = "14" Or rep = "20" Or Rep = "23" Then
VarNum = VaroldNum + 1
operator.Text = Varoperator
ElseIf Rep = "05" Or Rep = "06" Then
VarNum = Varold - 15
Operator.Text = VarNum
end If
End If
EndIf

Merci d'avance

Polly.

1 réponse

Armojax Messages postés 1858 Date d'inscription mercredi 19 janvier 2005 Statut Membre Dernière intervention 22 mars 2024 1 527
14 oct. 2005 à 18:52
Salut polly,

Je ne vois pas de problème, à part 2 End If en trop en fin de proc.
Je conseillerais plutôt, pour la clarté, l'utilisation de Select Case :
Select Case Rep
  Case "01", "02", "03"
    VarNum = Varold
    Operator.Text = Varoperator
  Case "14", "20", "23"
    VarNum = VaroldNum + 1
    Operator.Text = Varoperator
  Case "05", "06"
    VarNum = Varold - 15
    Operator.Text = VarNum
End Select
-1