Nombre au hasard sur VB

Résolu
xXfalcon68Xx Messages postés 13 Statut Membre -  
xXfalcon68Xx Messages postés 13 Statut Membre -
Je suis entrain de faire un programe pour tirer des nombre au hasard. qui suivant ceux-ci ouvrent differentes fenètre.
Mais sa ne marche pas ! aidez moi SVP

Voila mon programme
Private Sub CommandButton1_Click()
Rnd 0 * 11
Rnd = x
If x = 0 Then
UserForm4.Show
End If
If x = 1 Then
UserForm5.Show
End If
If x = 2 Then
UserForm6.Show
End If
If x = 3 Then
UserForm7.Show
End If
If x = 4 Then
UserForm8.Show
End If
If x = 5 Then
UserForm9.Show
End If
If x = 6 Then
UserForm10.Show
End If
If x = 7 Then
UserForm11.Show
End If
If x = 8 Then
UserForm12.Show
End If
If x = 9 Then
UserForm13.Show
End If
If x = 10 Then
UserForm3.Show
End If
End Sub

2 réponses

  1. ccm81 Messages postés 11033 Statut Membre 2 434
     
    Bonjour

    1.
    remplacer
    Rnd 0 * 11
    Rnd = x
    par
    x = int(11*Rnd)

    2. Pour la suite un select case x serait plus simple/clair

    Select Case x
    Case 0: UserForm4.Show
    Case 1: UserForm5.Show
    ...
    End Select

    Cdlmnt
    0
  2. xXfalcon68Xx Messages postés 13 Statut Membre
     
    Merco beaucoup. Sa marche a merveille !
    0