1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
| Option Explicit
Private Sub Grille_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
If ListBox1.ListCount = 0 Then Exit Sub
Dim ou As Integer, oux As Integer, ouy As Integer
ou = ((Y \ (Grille.Height / 7)) * 7) + (X \ (Grille.Width / 7)) + 1
Controls(ListBox1.List(0)).Caption = ou
oux = IIf(ou Mod 7 > 0, Abs(((ou Mod 7) - 1)), 6)
ouy = IIf(ou Mod 7 = 0, (ou \ 7) - 1, ou \ 7)
With Controls(ListBox1.List(0))
.Move Grille.Left + 2 + (Grille.Width / 7) * oux, Grille.Top + (Grille.Height / 7) * ouy
.Visible = True
.Tag = ou
End With
ListBox1.RemoveItem 0
End Sub
Private Sub coche1_Click()
couic coche1
End Sub
Private Sub coche2_Click()
couic coche2
End Sub
Private Sub coche3_Click()
couic coche3
End Sub
Private Sub coche4_Click()
couic coche4
End Sub
Private Sub coche5_Click()
couic coche5
End Sub
Private Sub coche6_Click()
couic coche6
End Sub
Private Sub couic(quoi As Control)
ListBox1.AddItem quoi.Name
quoi.Visible = False
End Sub
Private Sub command1_Click()
Dim msg As String, nb As Integer, i As Integer
msg = ""
For i = 1 To 6
If Controls("coche" & i).Visible Then
msg = msg & vbCrLf & Controls("coche" & i).Tag
nb = nb + 1
End If
Next
MsgBox nb & " numeros joués : " & vbCrLf & msg
End Sub
Private Sub UserForm_Initialize()
'tout ceci uniquement pour faire à ta place ce quue tu pourrais faire dans la fenêtre des propriétés !
'sauf en ce qui concerne les lignes (en boucle) marquées ' <============
' (il reste fort peu de code "réel", n'est-ce-pas ?)
command1.Caption = "contrôler"
Dim combien As String, i As Integer, j As Integer
With Grille
.BackColor = RGB(255, 220, 255): ForeColor = 0
.Caption = ""
.Font.Name = "Courier New": .Font.Size = 16
.Width = 200: .Height = 120
.BorderStyle = fmBorderStyleSingle
End With
ListBox1.Visible = False
For i = 0 To 6 ' <============
For j = 1 To 7 ' <============
combien = CStr(j + (i * 7)) ' <============
combien = IIf(Len(combien) < 2, Format(combien, " 0 "), Format(combien, "0 ")) ' <============
Grille.Caption = Grille.Caption & combien ' <============
Next ' <============
Grille.Caption = Grille.Caption & vbCrLf ' <============
Next
For i = 1 To 6 ' <============
With Controls("coche" & i) ' <============
.Font.Name = Grille.Font.Name: .Font.Size = Grille.Font.Size: .FontBold = True
.BackColor = vbRed: .ForeColor = vbWhite
.Width = 22: .Height = 16
.Visible = False
ListBox1.AddItem "coche" & i ' <============
End With ' <============
Next
End Sub |
Partager