Accueil > > > VACHE TAUREAU
VACHE TAUREAU
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
- 02 octobre 2009 22:46:26 :
- 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.
Sources du même auteur
Sources de la même categorie
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
|
Derniers Blogs
PRéSENTATION DES API REST DE WINDOWS AZURE : LISTER LES COMPTES DE STORAGEPRéSENTATION DES API REST DE WINDOWS AZURE : LISTER LES COMPTES DE STORAGE par richardc
http://www.c2idotnet.com/articles/presentation-des-api-rest-de-windows-azure-lister-les-comptes-de-storage
Désolé pour "toto", mais c2i existait avant blogs.developpeur.org et c'est mon site "officiel" ;-) ...
Cliquez pour lire la suite de l'article par richardc [HTML5] SLIDES ET DéMOS : AUTOUR DU W3C , NOUVEAUX STANDARDS ET WEB MOBILE (LILLE)[HTML5] SLIDES ET DéMOS : AUTOUR DU W3C , NOUVEAUX STANDARDS ET WEB MOBILE (LILLE) par Gio
Très bonne après-midi passée lors cette conférence avec le W3C, organisée par L' Inria sur les nouveaux standards, ce Mardi 14 Février, on sent vraiment que çà bosse au W3C, et l'avenir est très très prometteur pour le HTML5, notamment ...
Cliquez pour lire la suite de l'article par Gio GESTION D'EXCEPTION AVEC LES TASKSGESTION D'EXCEPTION AVEC LES TASKS par richardc
Nous avons vu dans un précédent article comment utiliser Task pour effectuer des opérations dans un autre thread.
Malheureusement, comme tout le monde n'est pas parfait, il se peut que cette exécution se passe mal et qu'une exception se produise.
La...
Cliquez pour lire la suite de l'article par richardc DéMARRONS AVEC LES TASKSDéMARRONS AVEC LES TASKS par richardc
Que vous le vouliez ou non, le développement multi-tâche est maintenant une obligation pour toute nouvelle application. Il est donc vital d'en comprendre les mécanismes et de s'y mettre le plus tôt possible.
En attendant le .NET Framework 4.5 avec le...
Cliquez pour lire la suite de l'article par richardc
Logiciels
DocTranslate (V3.1.0.0)DOCTRANSLATE (V3.1.0.0)DocTranslate est un traducteur de document Microsoft Word, PowerPoint et Excel. Il permet d'autom... Cliquez pour télécharger DocTranslate Tribler (2012)TRIBLER (2012)Tribler est un client pair à pair (P2P/Peer-to-Peer) open source avec la capacité de regarder des... Cliquez pour télécharger Tribler OneSwarm (2012)ONESWARM (2012)Le peer-to-peer qui protège votre vie privée, c'est OneSwarm.
Ce logiciel de peer-to-peer crypté... Cliquez pour télécharger OneSwarm PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V8.4)PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V8.4)PONAMEDIA TV DEVIENS HELLLOOO FLASH
LA TV SUR VOTRE ORDINATEUR.
Toute une plateforme Multi... Cliquez pour télécharger PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO Academy System (17.2.1.0)ACADEMY SYSTEM (17.2.1.0)Logiciel de gestion des établissements.
- élèves/étudiants (inscription, dossier, absence...)
-... Cliquez pour télécharger Academy System
|