Nombre au hasard sur VB

Résolu/Fermé
xXfalcon68Xx Messages postés 12 Date d'inscription mercredi 18 juin 2014 Statut Membre Dernière intervention 19 juin 2014 - 18 juin 2014 à 11:18
xXfalcon68Xx Messages postés 12 Date d'inscription mercredi 18 juin 2014 Statut Membre Dernière intervention 19 juin 2014 - 19 juin 2014 à 08:15
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
A voir également:

2 réponses

ccm81 Messages postés 10851 Date d'inscription lundi 18 octobre 2010 Statut Membre Dernière intervention 16 avril 2024 2 404
18 juin 2014 à 16:09
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
xXfalcon68Xx Messages postés 12 Date d'inscription mercredi 18 juin 2014 Statut Membre Dernière intervention 19 juin 2014
19 juin 2014 à 08:15
Merco beaucoup. Sa marche a merveille !
0