|
Trouver une ressource
Vous ne trouvez pas de réponse à votre problème ? Alors posez la question dans le forum. Souvenez-vous qu'il n'y a jamais de question bête, mais rester dans l'ignorance parce que l'on n'ose pas poser une question, ça c'est une erreur !
VACHE TAUREAU /CHIHAOUI_MED@HOTMAIL.COM/
Information sur la source
Description
Salut ! bref, un jeu populaire Vache Taureau! l'Ordi génère un nombre aléatoire et l'utilisateur de le trouvé ! Une simple application avec une jolie animation ! a vous de les découvrir.
Source
- Option Explicit
- Dim nombre As Long
- Dim nombrech As String
-
- Private Sub cmdaide_Click()
- Form2.Show
- End Sub
-
- Private Sub cmdgo_Click()
- 'animation
- Picture1.DrawWidth = 15
- Picture2.DrawWidth = 15
- Picture3.DrawWidth = 15
- Dim x, y, color As Single
- Dim i As Integer
- For i = 1 To 15000
- x = Picture1.ScaleWidth * Rnd
- y = Picture1.ScaleHeight * Rnd
- color = RGB(256 * Rnd, 256 * Rnd, 256 * Rnd)
- Picture1.PSet (x, y), color
- x = Picture2.ScaleWidth * Rnd
- y = Picture2.ScaleHeight * Rnd
- color = RGB(256 * Rnd, 256 * Rnd, 256 * Rnd)
- Picture2.PSet (x, y), color
- x = Picture3.ScaleWidth * Rnd
- y = Picture3.ScaleHeight * Rnd
- color = RGB(256 * Rnd, 256 * Rnd, 256 * Rnd)
- Picture3.PSet (x, y), color
- DoEvents
- Next
- 'traitement vt
- If optfacile.Value = True Then
- If IsNumeric(txttent.Text) And Len(txttent.Text) = 4 Then
- Dim taur, vach As Integer
- taur = 0: vach = 0
- For i = 1 To 4
- If Mid(txttent.Text, i, 1) = Mid(nombrech, i, 1) Then
- taur = taur + 1
- End If
- Next i
- Dim j As Integer
- For i = 1 To 4
- For j = 1 To 4
- If Mid(txttent.Text, i, 1) = Mid(nombrech, j, 1) Then
- vach = vach + 1
- End If
- Next
- Next
- vach = vach - taur
- lsttent.AddItem (txttent.Text & " : " & taur & "T" & " & " & vach & "V")
- txttent.Text = "": txttent.SetFocus
- If taur = 4 Then
- cmdpermuter.Visible = False
- seelight
- Label1.Visible = True
- txttent.Visible = False
- lblres.Caption = "the number is : " & nombrech
- End If
- Else
- lblres = "nombre erroné"
- End If
- End If
- If optmoyen.Value = True Then
- If IsNumeric(txttent.Text) And Len(txttent.Text) = 5 Then
- taur = 0: vach = 0
- For i = 1 To 5
- If Mid(txttent.Text, i, 1) = Mid(nombrech, i, 1) Then
- taur = taur + 1
- End If
- Next i
- For i = 1 To 5
- For j = 1 To 5
- If Mid(txttent.Text, i, 1) = Mid(nombrech, j, 1) Then
- vach = vach + 1
- End If
- Next
- Next
- vach = vach - taur
- lsttent.AddItem (txttent.Text & " : " & taur & "T" & " & " & vach & "V")
- txttent.Text = "": txttent.SetFocus
- If taur = 5 Then
- cmdpermuter.Visible = False
- seelight
- Label1.Visible = True
- txttent.Visible = False
- lblres.Caption = "the number is : " & nombrech
- End If
- Else
- lblres = "nombre erroné"
- End If
- End If
- If optdifficile.Value = True Then
- If IsNumeric(txttent.Text) And Len(txttent.Text) = 6 Then
- taur = 0: vach = 0
- For i = 1 To 6
- If Mid(txttent.Text, i, 1) = Mid(nombrech, i, 1) Then
- taur = taur + 1
- End If
- Next i
- For i = 1 To 6
- For j = 1 To 6
- If Mid(txttent.Text, i, 1) = Mid(nombrech, j, 1) Then
- vach = vach + 1
- End If
- Next
- Next
- vach = vach - taur
- lsttent.AddItem (txttent.Text & " : " & taur & "T" & " & " & vach & "V")
- txttent.Text = "": txttent.SetFocus
- If taur = 6 Then
- cmdpermuter.Visible = False
- seelight
- Label1.Visible = True
- txttent.Visible = False
- lblres.Caption = "the number is : " & nombrech
- End If
- Else
- lblres = "nombre erroné"
- End If
- End If
- End Sub
- Private Sub seelight()
- Timer1.Enabled = True
- Shape1.FillColor = vbYellow
- Shape2.FillColor = vbYellow
- Shape1.FillStyle = 1
- Timer1.Interval = 150
- End Sub
- Private Sub cmdinit_Click()
- cmdpermuter.Visible = True
- Label1.Visible = False
- txttent.Visible = True
- Timer1.Enabled = False
- Shape1.FillStyle = 1
- Shape2.FillStyle = 1
- lsttent.Clear
- txttent.Text = "": txttent.SetFocus
- lblres.Caption = ""
- Dim ok As Boolean
- Dim i, j As Integer
- If optfacile.Value = True Then
- Do
- ok = True
- Randomize
- nombre = (Rnd * 9999) + 1
- nombrech = nombre
- For i = 1 To 3
- For j = i + 1 To 4
- If Mid(nombrech, i, 1) = Mid(nombrech, j, 1) Then
- ok = False
- End If
- Next
- Next
- Loop Until Len(nombrech) = 4 And ok
- Else
- If optmoyen.Value = True Then
- Do
- ok = True
- Randomize
- nombre = (Rnd * 99999) + 1
- nombrech = nombre
- For i = 1 To 4
- For j = i + 1 To 5
- If Mid(nombrech, i, 1) = Mid(nombrech, j, 1) Then
- ok = False
- End If
- Next
- Next
- Loop Until Len(nombrech) = 5 And ok
- Else
- If optdifficile.Value = True Then
- Do
- ok = True
- Randomize
- nombre = (Rnd * 999999) + 1
- nombrech = nombre
- For i = 1 To 5
- For j = i + 1 To 6
- If Mid(nombrech, i, 1) = Mid(nombrech, j, 1) Then
- ok = False
- End If
- Next
- Next
- Loop Until Len(nombrech) = 6 And ok
- End If
- End If
- End If
- End Sub
-
- Private Sub cmdloser_Click()
- cmdpermuter.Visible = False
- lblres.Caption = nombrech
- Timer1.Enabled = True
- Timer1.Interval = 150
- Shape1.FillStyle = 1
- Shape1.FillColor = vbRed
- Shape2.FillColor = vbRed
- End Sub
-
- Private Sub cmdpermuter_Click()
- If cmdpermuter.Caption = "}" Then
- cmdpermuter.Caption = "{"
- Form1.Width = Form1.Width + 5940
- Else
- cmdpermuter.Caption = "}"
- Form1.Width = Form1.Width - 5940
- End If
- End Sub
-
- Private Sub cmdquit_Click()
- If MsgBox(" do you really want to exit this application ", vbYesNo, "attention") = vbYes Then
- If MsgBox("hey you need to repeat the game !", vbYesNo, "ya m3allem brassommek win meshi") = vbNo Then
- End
- End If
- End If
- End Sub
-
- Private Sub Form_Load()
- cmdpermuter.Visible = True
- Form1.Width = 6735
- lsttent.Clear
- Dim ok As Boolean
- Dim i, j As Integer
- If optfacile.Value = True Then
- Do
- ok = True
- Randomize
- nombre = (Rnd * 9999) + 1
- nombrech = nombre
- For i = 1 To 3
- For j = i + 1 To 4
- If Mid(nombrech, i, 1) = Mid(nombrech, j, 1) Then
- ok = False
- End If
- Next
- Next
- Loop Until Len(nombrech) = 4 And ok
- Else
- If optmoyen.Value = True Then
- Do
- ok = True
- Randomize
- nombre = (Rnd * 99999) + 1
- nombrech = nombre
- For i = 1 To 4
- For j = i + 1 To 5
- If Mid(nombrech, i, 1) = Mid(nombrech, j, 1) Then
- ok = False
- End If
- Next
- Next
- Loop Until Len(nombrech) = 5 And ok
- Else
- If optdifficile.Value = True Then
- Do
- ok = True
- Randomize
- nombre = (Rnd * 999999) + 1
- nombrech = nombre
- For i = 1 To 5
- For j = i + 1 To 6
- If Mid(nombrech, i, 1) = Mid(nombrech, j, 1) Then
- ok = False
- End If
- Next
- Next
- Loop Until Len(nombrech) = 6 And ok
- End If
- End If
- End If
- End Sub
-
- Private Sub Timer1_Timer()
- If Shape1.FillStyle = 1 Then
- Shape1.FillStyle = 0
- Shape2.FillStyle = 1
- Label1.Visible = False
- Else
- Shape1.FillStyle = 1
- Shape2.FillStyle = 0
- Label1.Visible = True
- End If
- End Sub
- Private Sub txttent_GotFocus()
- txttent.Text = ""
- End Sub
Option Explicit
Dim nombre As Long
Dim nombrech As String
Private Sub cmdaide_Click()
Form2.Show
End Sub
Private Sub cmdgo_Click()
'animation
Picture1.DrawWidth = 15
Picture2.DrawWidth = 15
Picture3.DrawWidth = 15
Dim x, y, color As Single
Dim i As Integer
For i = 1 To 15000
x = Picture1.ScaleWidth * Rnd
y = Picture1.ScaleHeight * Rnd
color = RGB(256 * Rnd, 256 * Rnd, 256 * Rnd)
Picture1.PSet (x, y), color
x = Picture2.ScaleWidth * Rnd
y = Picture2.ScaleHeight * Rnd
color = RGB(256 * Rnd, 256 * Rnd, 256 * Rnd)
Picture2.PSet (x, y), color
x = Picture3.ScaleWidth * Rnd
y = Picture3.ScaleHeight * Rnd
color = RGB(256 * Rnd, 256 * Rnd, 256 * Rnd)
Picture3.PSet (x, y), color
DoEvents
Next
'traitement vt
If optfacile.Value = True Then
If IsNumeric(txttent.Text) And Len(txttent.Text) = 4 Then
Dim taur, vach As Integer
taur = 0: vach = 0
For i = 1 To 4
If Mid(txttent.Text, i, 1) = Mid(nombrech, i, 1) Then
taur = taur + 1
End If
Next i
Dim j As Integer
For i = 1 To 4
For j = 1 To 4
If Mid(txttent.Text, i, 1) = Mid(nombrech, j, 1) Then
vach = vach + 1
End If
Next
Next
vach = vach - taur
lsttent.AddItem (txttent.Text & " : " & taur & "T" & " & " & vach & "V")
txttent.Text = "": txttent.SetFocus
If taur = 4 Then
cmdpermuter.Visible = False
seelight
Label1.Visible = True
txttent.Visible = False
lblres.Caption = "the number is : " & nombrech
End If
Else
lblres = "nombre erroné"
End If
End If
If optmoyen.Value = True Then
If IsNumeric(txttent.Text) And Len(txttent.Text) = 5 Then
taur = 0: vach = 0
For i = 1 To 5
If Mid(txttent.Text, i, 1) = Mid(nombrech, i, 1) Then
taur = taur + 1
End If
Next i
For i = 1 To 5
For j = 1 To 5
If Mid(txttent.Text, i, 1) = Mid(nombrech, j, 1) Then
vach = vach + 1
End If
Next
Next
vach = vach - taur
lsttent.AddItem (txttent.Text & " : " & taur & "T" & " & " & vach & "V")
txttent.Text = "": txttent.SetFocus
If taur = 5 Then
cmdpermuter.Visible = False
seelight
Label1.Visible = True
txttent.Visible = False
lblres.Caption = "the number is : " & nombrech
End If
Else
lblres = "nombre erroné"
End If
End If
If optdifficile.Value = True Then
If IsNumeric(txttent.Text) And Len(txttent.Text) = 6 Then
taur = 0: vach = 0
For i = 1 To 6
If Mid(txttent.Text, i, 1) = Mid(nombrech, i, 1) Then
taur = taur + 1
End If
Next i
For i = 1 To 6
For j = 1 To 6
If Mid(txttent.Text, i, 1) = Mid(nombrech, j, 1) Then
vach = vach + 1
End If
Next
Next
vach = vach - taur
lsttent.AddItem (txttent.Text & " : " & taur & "T" & " & " & vach & "V")
txttent.Text = "": txttent.SetFocus
If taur = 6 Then
cmdpermuter.Visible = False
seelight
Label1.Visible = True
txttent.Visible = False
lblres.Caption = "the number is : " & nombrech
End If
Else
lblres = "nombre erroné"
End If
End If
End Sub
Private Sub seelight()
Timer1.Enabled = True
Shape1.FillColor = vbYellow
Shape2.FillColor = vbYellow
Shape1.FillStyle = 1
Timer1.Interval = 150
End Sub
Private Sub cmdinit_Click()
cmdpermuter.Visible = True
Label1.Visible = False
txttent.Visible = True
Timer1.Enabled = False
Shape1.FillStyle = 1
Shape2.FillStyle = 1
lsttent.Clear
txttent.Text = "": txttent.SetFocus
lblres.Caption = ""
Dim ok As Boolean
Dim i, j As Integer
If optfacile.Value = True Then
Do
ok = True
Randomize
nombre = (Rnd * 9999) + 1
nombrech = nombre
For i = 1 To 3
For j = i + 1 To 4
If Mid(nombrech, i, 1) = Mid(nombrech, j, 1) Then
ok = False
End If
Next
Next
Loop Until Len(nombrech) = 4 And ok
Else
If optmoyen.Value = True Then
Do
ok = True
Randomize
nombre = (Rnd * 99999) + 1
nombrech = nombre
For i = 1 To 4
For j = i + 1 To 5
If Mid(nombrech, i, 1) = Mid(nombrech, j, 1) Then
ok = False
End If
Next
Next
Loop Until Len(nombrech) = 5 And ok
Else
If optdifficile.Value = True Then
Do
ok = True
Randomize
nombre = (Rnd * 999999) + 1
nombrech = nombre
For i = 1 To 5
For j = i + 1 To 6
If Mid(nombrech, i, 1) = Mid(nombrech, j, 1) Then
ok = False
End If
Next
Next
Loop Until Len(nombrech) = 6 And ok
End If
End If
End If
End Sub
Private Sub cmdloser_Click()
cmdpermuter.Visible = False
lblres.Caption = nombrech
Timer1.Enabled = True
Timer1.Interval = 150
Shape1.FillStyle = 1
Shape1.FillColor = vbRed
Shape2.FillColor = vbRed
End Sub
Private Sub cmdpermuter_Click()
If cmdpermuter.Caption = "}" Then
cmdpermuter.Caption = "{"
Form1.Width = Form1.Width + 5940
Else
cmdpermuter.Caption = "}"
Form1.Width = Form1.Width - 5940
End If
End Sub
Private Sub cmdquit_Click()
If MsgBox(" do you really want to exit this application ", vbYesNo, "attention") = vbYes Then
If MsgBox("hey you need to repeat the game !", vbYesNo, "ya m3allem brassommek win meshi") = vbNo Then
End
End If
End If
End Sub
Private Sub Form_Load()
cmdpermuter.Visible = True
Form1.Width = 6735
lsttent.Clear
Dim ok As Boolean
Dim i, j As Integer
If optfacile.Value = True Then
Do
ok = True
Randomize
nombre = (Rnd * 9999) + 1
nombrech = nombre
For i = 1 To 3
For j = i + 1 To 4
If Mid(nombrech, i, 1) = Mid(nombrech, j, 1) Then
ok = False
End If
Next
Next
Loop Until Len(nombrech) = 4 And ok
Else
If optmoyen.Value = True Then
Do
ok = True
Randomize
nombre = (Rnd * 99999) + 1
nombrech = nombre
For i = 1 To 4
For j = i + 1 To 5
If Mid(nombrech, i, 1) = Mid(nombrech, j, 1) Then
ok = False
End If
Next
Next
Loop Until Len(nombrech) = 5 And ok
Else
If optdifficile.Value = True Then
Do
ok = True
Randomize
nombre = (Rnd * 999999) + 1
nombrech = nombre
For i = 1 To 5
For j = i + 1 To 6
If Mid(nombrech, i, 1) = Mid(nombrech, j, 1) Then
ok = False
End If
Next
Next
Loop Until Len(nombrech) = 6 And ok
End If
End If
End If
End Sub
Private Sub Timer1_Timer()
If Shape1.FillStyle = 1 Then
Shape1.FillStyle = 0
Shape2.FillStyle = 1
Label1.Visible = False
Else
Shape1.FillStyle = 1
Shape2.FillStyle = 0
Label1.Visible = True
End If
End Sub
Private Sub txttent_GotFocus()
txttent.Text = ""
End Sub
Historique
- 13 mars 2008 22:21:42 :
- j'ai ajouté un capture d'ecran !
- 13 mars 2008 22:32:23 :
- j'ai changé la capture d'écran
- 13 mars 2008 22:36:31 :
- j'ai changé la capture d'écran pour qu'elle soit plus clair !
- 13 mars 2008 22:36:41 :
- j'ai changé la capture d'écran pour qu'elle soit plus clair !
- 13 mars 2008 22:38:08 :
- Capture d'ecran plus clair
- 01 août 2008 08:26:53 :
- amélioration du titre
Sources du même auteur
Sources de la même categorie
Sources en rapport avec celle ci
Commentaires et avis
Discussions en rapport avec ce code source dans le forum
Comment augmenter le nombre de chiffres après la virgule? [ par Olisoft ]
Je cherche comment je peux augmenter le nombre de chiffres après la virgule dans un "label" ou un "text" après un calcul. J'arrive seulement à avoir
tous les chiffres du générateur aléatoire ? [ par neo12 ]
Bonjour, j'ai un petit pb...voiçi le postulat :j'utilise une instruction PAINTPICTURE pour faire apparaître une image par mosaïque (l'image se remplit
probeme programmation [ par chris708 ]
j'ai recemment telecharger un prog. vbpermettant la recherche de fichiers sur un support,ayant acquis enormement de cliparts,a la recherche de fichier
Problème avec des Randomize [ par Vbsupernul ]
Bonjour à tous;Voilà, j'ai un truc:Dim nombre As DoubleRandomize Timernombre=(Rnd * 9999999999#)Comment faire pour obliger à trouver un nombre à 10 ch
saisie et calacul de nombre decimale [ par stef01 ]
je suis a la recherche de quelle fonction et exemple pour les metres en application dans mon prejet je fais une saisie de chiffres pour faire des calc
random d'un nombre avec priorité [ par pioug43 ]
J'aimerais savoir s'il n'existe pas une fonction ou autre qui me permettrait de sortir des chiffres avec une priorité.Ex:mes chiffres 1,2,3,4,5,6le 1
Recherche du nombre de fois ou on voit ce qu'on demande [ par Ealendil ]
Bonjour,je voudrais savoir si vous saviez la commande (je suppose que c'est possible avec excel ) pour dans un tableau compter le nombre de fois ou pa
recuperer le nombre de rep ? recherche rep dans chak rep [ par gnosis35 ]
j'aimerai creer un variable de type integer qui contient le nombre de repertoire d'un chemin que je saisi dans un text box comment faire ??je dois uti
Recherche partiel sous access [ par poparize ]
Salut tout le monde ! Voici la dernière colle qui me pause des soucis ! Je souhaite faire une recherche qui remonterai toutes les villes commençant pa
Lecture chiffre par chiffre d'un fichier ! [ par ZogStriP ]
Bonjour tout le monde et Joyeux Noël !!Je voudrais savoir comment faire pour lire un tableau de chiffres d'un fichier !!Exemple : (contenue de monFich
|
Téléchargements
Logiciels à télécharger sur le même thème :
|