Et en vba

bandinos -  
pijaku Messages postés 13513 Date d'inscription   Statut Modérateur Dernière intervention   -
Bonjour cher ami,

comment pourrais-je écrire ce code en vba stp
exemple:
si b égal a zéros alors
ac=2*5
si b différent de zéros alors
ac=2*5*4
merci de votre aide

1 réponse

  1. pijaku Messages postés 13513 Date d'inscription   Statut Modérateur Dernière intervention   2 773
     
    Salut mon pote!
    Comme ceci :
    If b = 0 Then
        ac=2*5
    Else
        ac=2*5*4 
    End If
    1
    1. bandinos
       
      slut poto
      ca me calcul que b=0
      0
    2. pijaku Messages postés 13513 Date d'inscription   Statut Modérateur Dernière intervention   2 773
       
      ça me trouble...
      Tu dois bien te tromper quelque part...
      Essaye ceci :
      Sub test()
      Dim b As Integer, ac As Integer
      
      MsgBox "Si b = 1"
      b = 1
      If b = 0 Then
          ac = 2 * 5
      Else
          ac = 2 * 5 * 4
      End If
      MsgBox "Si b=1 alors ac = " & ac & " soit 2*5*4"
      
      MsgBox "Maintenant essayons avec b = 0"
      b = 0
      If b = 0 Then
          ac = 2 * 5
      Else
          ac = 2 * 5 * 4
      End If
      MsgBox "Si b=0 alors ac = " &ac & " soit 2*5"
      End Sub
      0