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

Catégorie :Divers Classé sous : nombre, recherche, vache, taureau, chiffres Niveau : Débutant Date de création : 03/03/2008 Date de mise à jour : 01/08/2008 08:26:53 Vu / téléchargé: 4 392 / 282

Note :
Aucune note

Commentaire sur cette source (3)
Ajouter un commentaire et/ou une note

Description

Cliquez pour voir la capture en taille normale
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

Fichier Zip

Pour les "Membres Club", vous pouvez télécharger directement un fichier contenu dans le zip sans télécharger le zip en entier !
  •   vache taureau
    • Form1.frmTélécharger ce fichier [Réservé aux membres club]Voir ce fichier17 492 octets
    • Form1.frxTélécharger ce fichier [Réservé aux membres club]112 649 octets
    • Form2.frmTélécharger ce fichier [Réservé aux membres club]Voir ce fichier5 989 octets
    • Form2.frxTélécharger ce fichier [Réservé aux membres club]22 949 octets
    • FOXUSER.DBFTélécharger ce fichier [Réservé aux membres club]905 octets
    • FOXUSER.FPTTélécharger ce fichier [Réservé aux membres club]5 056 octets
    • MSSCCPRJ.SCCTélécharger ce fichier [Réservé aux membres club]195 octets
    • Projet1vbp.vbpTélécharger ce fichier [Réservé aux membres club]Voir ce fichier735 octets
    • Projet1vbp.vbwTélécharger ce fichier [Réservé aux membres club]Voir ce fichier99 octets
    • vache-taureau.zipTélécharger ce fichier [Réservé aux membres club]112 266 octets

Télécharger le zip

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

Commentaires et avis

signaler à un administrateur
Commentaire de MadM@tt le 04/03/2008 00:35:51

Tu devrais apprendre à indenter ton code, à le commenter, à séparer chaque fonction, à mettre les déclarations de variables en début de chaque fonction, à nommer tes controles de façon plus explicite et à mieux présenter ta source.
(J'ai pas testé le code en soit)
Bonne soirée

signaler à un administrateur
Commentaire de 2mohamed2 le 04/03/2008 16:24:35

Salut !
Tu as raison parce que mon programme n'est plus clair !
Je suis nouveau en VB et en "vbfrance" , donc je vais prendre vos critiques sérieusement a la prochaine fois ! dans un autre programme !
Merci pour votre indication !

signaler à un administrateur
Commentaire de PWM63 le 10/03/2008 10:59:47

En complément de MadM@tt, j'ajouterai :
choisir une seule langue pour tous les messages, ou laisser le choix de celle à afficher.

Ajouter un commentaire

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


Nos sponsors

Sondage...

CalendriCode

Décembre 2008
LMMJVSD
1234567
891011121314
15161718192021
22232425262728
293031    

Consulter la suite du CalendriCode

Téléchargements

Logiciels à télécharger sur le même thème :



Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel BAÏSE, Merci à Vincent pour ses précieux conseils
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés
Temps d'éxécution de la page : 0,374 sec

Google Coop CodeS-SourceS Google Coop CodeS-SourceS


Certaines images présentes sur le site (notament certains avatars) sont issues des collections IconShock, donc si vous souhaitez utiliser ces icons vous devez les acheter, ne les copiez pas et ne utilisez pas dans vos sites et applications sans les avoir commandé.