JEux utilisateur : probléme

Résolu/Fermé
jijudu Messages postés 211 Date d'inscription jeudi 15 mai 2008 Statut Membre Dernière intervention 3 septembre 2009 - 14 oct. 2008 à 12:49
Polux31 Messages postés 6917 Date d'inscription mardi 25 septembre 2007 Statut Membre Dernière intervention 1 novembre 2016 - 14 oct. 2008 à 14:01
Bonjour,

Je voudrais mettre dans un tableau certain chiffre. Lorsque l'utilisateur rentre un nombre via l'inputbox le programme analyse sa réponse


Voici mon code qui ne marche pas :
Tableau22 = Array("1", "3", "5")
Dim reponse As Integer
reponse = InputBox("nombre : ")

If reponse = Tableau22 Then
    MsgBox "PERDU"
else
 msgbox "ok"
End If



MERCI
A voir également:

3 réponses

Polux31 Messages postés 6917 Date d'inscription mardi 25 septembre 2007 Statut Membre Dernière intervention 1 novembre 2016 1 204
14 oct. 2008 à 13:09
Bonjour,

Voilà un exemple :
Sub jeu()
Dim reponse As Integer

    reponse = InputBox("Nombre : ")
    If repOk(reponse) = True Then
        MsgBox "Bravo"
    Else
        MsgBox "Perdu"
    End If
    
End Sub

Function repOk(ByVal nb As Integer) As Boolean
Dim i As Integer
Dim tableau22()

    tableau22 = Array(1, 3, 5)

    For i = LBound(tableau22()) To UBound(tableau22())
        If nb = tableau22(i) Then
            repOk = True
            Exit Function
        End If
    Next i

    repOk = False
    
End Function


Bonne continuation

;o)
-1
jijudu Messages postés 211 Date d'inscription jeudi 15 mai 2008 Statut Membre Dernière intervention 3 septembre 2009 3
14 oct. 2008 à 14:00
Merci bcp !
-1
Polux31 Messages postés 6917 Date d'inscription mardi 25 septembre 2007 Statut Membre Dernière intervention 1 novembre 2016 1 204
14 oct. 2008 à 14:01
De rien

Bon courage pour la suite.

;o)
-1