Bouton aléatoire

cs_jonathan33 Messages postés 3 Date d'inscription dimanche 11 avril 2004 Statut Membre Dernière intervention 24 septembre 2006 - 24 sept. 2006 à 17:37
cs_jonathan33 Messages postés 3 Date d'inscription dimanche 11 avril 2004 Statut Membre Dernière intervention 24 septembre 2006 - 24 sept. 2006 à 20:34
Bonjours ,

J'essaye de rajouter dans mon code un autre command aléatoire sauve j'arrive pas a mettre le 3éme Command aléatoire et le nom de la command est CmdNbAleatoire

voisie le code :

En haut du programme
Public Function probabilités1() As Boolean
    Randomize Date + Timer
    If Rnd > 0.95 Then
    probabilités1 = True
    Else: probabilités1 = False
    End If
End Function
quand on clique sur la premier command

    If probabilités1() = True Then
    CmdAideSortie.Visible = True
    Else: CmdExit(11 * Rnd).Visible = True
    End If
merci d'avance

4 réponses

Julien237 Messages postés 883 Date d'inscription vendredi 3 novembre 2000 Statut Membre Dernière intervention 3 mars 2009 7
24 sept. 2006 à 18:41
Mince j'ai rien compris mais alors la, rien du tout...
Je vais demander à ma soeur qui est interprète si elle comprends "J'essaye de rajouter dans mon code un autre command aléatoire sauve
j'arrive pas a mettre le 3éme Command aléatoire et le nom de la command
est CmdNbAleatoire"...

Et puis si tu veux qu'on te réponde, pose une question...

Julien.
0
cs_jonathan33 Messages postés 3 Date d'inscription dimanche 11 avril 2004 Statut Membre Dernière intervention 24 septembre 2006
24 sept. 2006 à 19:58
comment je peux ajouter un autre command dans mon code ?
0
econs Messages postés 4030 Date d'inscription mardi 13 mai 2003 Statut Membre Dernière intervention 23 décembre 2008 24
24 sept. 2006 à 20:19
Salut,

Si tu disposes d'un premier Command1, dont la propriété Index vaut 0, alors en faisant Load Command1(1), tu crées une copie de Command1(0).

Voir "Groupe de contrôles" dans l'outil de recherche de VBFrance

Manu

--------------------------------------------------------------------------------------------
Avant de poster un message, n'oubliez pas de consulter le reglement.
0
cs_jonathan33 Messages postés 3 Date d'inscription dimanche 11 avril 2004 Statut Membre Dernière intervention 24 septembre 2006
24 sept. 2006 à 20:34
le code complet
Dim ToucheCtrl As Boolean, ToucheA As Boolean, ToucheAlt As Boolean, Nb300 As Boolean

Public Function probabilités1() As Boolean
    Randomize Date + Timer
    If Rnd > 0.95 Then
    probabilités1 = True
    Else: probabilités1 = False
    End If
End Function

Private Sub CmdAideSortie_Click()
    Form3.Show
    Form3.OptAideSortie = True
End Sub

Private Sub CmdExit_MouseMove(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
    CmdExit(0).Visible = False
    CmdExit(1).Visible = False
    CmdExit(2).Visible = False
    CmdExit(3).Visible = False
    CmdExit(4).Visible = False
    CmdExit(5).Visible = False
    CmdExit(6).Visible = False
    CmdExit(7).Visible = False
    CmdExit(8).Visible = False
    CmdExit(9).Visible = False
    CmdExit(10).Visible = False
    CmdExit(11).Visible = False
    If probabilités1() = True Then
    CmdAideSortie.Visible = True
    Else: CmdExit(11 * Rnd).Visible = True
    End If
End Sub

Private Sub CmdExit1_Click()
    CmdExit1.Visible = False
    CmdExit2.Visible = False
    CmdExit(0).Caption = "oui"
    CmdExit(1).Caption = "oui"
    CmdExit(2).Caption = "oui"
    CmdExit(3).Caption = "oui"
    CmdExit(4).Caption = "oui"
    CmdExit(5).Caption = "oui"
    CmdExit(6).Caption = "oui"
    CmdExit(7).Caption = "oui"
    CmdExit(8).Caption = "oui"
    CmdExit(9).Caption = "oui"
    CmdExit(10).Caption = "oui"
    CmdExit(11).Caption = "oui"
    If probabilités1() = True Then
    CmdAideSortie.Visible = True
    Else: CmdExit(11 * Rnd).Visible = True
    End If
End Sub

Private Sub CmdExit2_Click()
    CmdExit1.Visible = False
    CmdExit2.Visible = False
    CmdExit(0).Caption = "Non"
    CmdExit(1).Caption = "Non"
    CmdExit(2).Caption = "Non"
    CmdExit(3).Caption = "Non"
    CmdExit(4).Caption = "Non"
    CmdExit(5).Caption = "Non"
    CmdExit(6).Caption = "Non"
    CmdExit(7).Caption = "Non"
    CmdExit(8).Caption = "Non"
    CmdExit(9).Caption = "Non"
    CmdExit(10).Caption = "Non"
    CmdExit(11).Caption = "Non"
    If probabilités1() = True Then
    CmdAideSortie.Visible = True
    Else: CmdExit(11 * Rnd).Visible = True
    End If
End Sub

Private Sub CmdNbAleatoire_Click(Index As Integer)
    EtiNbAleatoire = Fix(Rnd * 202)
End Sub

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    MinClavier.Enabled = True
    If KeyCode = 17 Then
    ToucheCtrl = True
    If ToucheAlt Then
    If ToucheA Then
    End If
    End If
    End If
    If KeyCode = 18 Then
    ToucheAlt = True
    If ToucheCtrl Then
    If ToucheA Then
    End If
    End If
    End If
    If KeyCode = 65 Then
    ToucheA = True
    If ToucheCtrl Then
    If ToucheAlt Then
    End
    End If
    End If
    End If
    If KeyCode = 51 Then
    If ToucheCtrl Then
    If ToucheAlt Then
    EtiNbAleatoire.Caption = 300
    End If
    End If
    End If
End Sub

Private Sub MinClavier_Timer()
    ToucheCtrl = False
    ToucheAlt = False
    ToucheA = False
End Sub
j'ai nommé CmdNbAleatoire le command1 et pour la fonction aléatoire le cmdexit et le cmdNbAleatoire ses pas la meme commande . Comment je peux le faire ?
0
Rejoignez-nous