Carre magique de 25 cases

Description

Ben c'est un carre magique de 5 par 5
Ya pas de bug connu (ben à ce que je sache, ça fait 5 minutes que je l'ai finit...)
Enfin, j'ai mit le ZIP -=ET=- la Source -=ET=- le screenshot :-D

Voila...

Suggestions grandement appréciées

Voodoo
~~~~~~~~~~~~~~~~
In Open Source We Trust

Source / Exemple :


Private Sub cmdverif_Click()
reu = 0  'variable "réussit"
For i = 0 To txtcase.Count - 1
    nombre = Val(txtcase.Item(i).Text)
    If nombre < 1 Or nombre > 25 Then
        MsgBox "Vous ne devez pas dépasser 25 !" & vbCrLf & "Le Zéro ne compte pas !", , "Nombres"
        txtcase.Item(i).SelStart = 0
        txtcase.Item(i).SelLength = Len(txtcase.Item(i))
        txtcase.Item(i).SetFocus
        Exit Sub
    End If
Next

For i = 0 To txtcase.Count - 1
    For p = o To txtcase.Count - 1
        If i = p Then
            Exit For
        Else
            If txtcase.Item(i) = txtcase.Item(p) Then
                MsgBox "Vous avez 2 chiffres identiques !"
                txtcase.Item(i).SelStart = 0
                txtcase.Item(i).SelLength = Len(txtcase.Item(i))
                txtcase.Item(i).SetFocus
                Exit Sub
            End If
        End If
    Next p
Next i

If lbltot.Item(0).Caption = "65" And lbltot.Item(1).Caption = "65" _
    And lbltot.Item(2).Caption = "65" And lbltot.Item(3).Caption = "65" _
        And lbltot.Item(4).Caption = "65" And lbltot.Item(5).Caption = "65" _
        And lbltot.Item(6).Caption = "65" And lbltot.Item(7).Caption = "65" _
        And lbltot.Item(8).Caption = "65" And lbltot.Item(9).Caption = "65" _
        And lbltot.Item(10).Caption = "65" And lbltot.Item(11).Caption = "65" Then
    reu = 1
Else
    reu = 0
End If

If reu = 0 Then
    MsgBox "Na...", , "Manqué !"
Else
    MsgBox "Bravo !!", , "Réussi !"
End If
End Sub

Private Sub cmdreset_Click()
For i = 0 To txtcase.Count - 1
    txtcase.Item(i).Text = ""
    txtcase.Item(i).MaxLength = 2
Next

For i = 0 To lbltot.Count - 1
    lbltot.Item(i).Caption = "0"
    lbltot.Item(i).FontSize = 10
Next
End Sub

Private Sub Form_Load()
For i = 0 To txtcase.Count - 1
    txtcase.Item(i).Text = ""
    txtcase.Item(i).MaxLength = 2
Next

For i = 0 To lbltot.Count - 1
    lbltot.Item(i).Caption = "0"
    lbltot.Item(i).FontSize = 10
Next
End Sub

Private Sub Form_Unload(Cancel As Integer)
End
End Sub

Private Sub txtcase_Change(Index As Integer)
For i = 0 To 4
    tot1 = tot1 + Val(txtcase.Item(i).Text)
Next
lbltot.Item(0).Caption = tot1
'/////////////////////////////////////////
For i = 5 To 9
    tot2 = tot2 + Val(txtcase.Item(i).Text)
Next
lbltot.Item(1).Caption = tot2
'/////////////////////////////////////////
For i = 10 To 14
    tot3 = tot3 + Val(txtcase.Item(i).Text)
Next
lbltot.Item(2).Caption = tot3
'/////////////////////////////////////////
For i = 15 To 19
    tot4 = tot4 + Val(txtcase.Item(i).Text)
Next
lbltot.Item(3).Caption = tot4
'/////////////////////////////////////////
For i = 20 To 24
    tot5 = tot5 + Val(txtcase.Item(i).Text)
Next
lbltot.Item(4).Caption = tot5
'/////////////////////////////////////////
For i = 0 To 20 Step 5
    tot6 = tot6 + Val(txtcase.Item(i).Text)
Next
lbltot.Item(10).Caption = tot6
'/////////////////////////////////////////
For i = 1 To 21 Step 5
    tot7 = tot7 + Val(txtcase.Item(i).Text)
Next
lbltot.Item(9).Caption = tot7
'/////////////////////////////////////////
For i = 2 To 22 Step 5
    tot8 = tot8 + Val(txtcase.Item(i).Text)
Next
lbltot.Item(8).Caption = tot8
'/////////////////////////////////////////
For i = 3 To 23 Step 5
    tot9 = tot9 + Val(txtcase.Item(i).Text)
Next
lbltot.Item(7).Caption = tot9
'/////////////////////////////////////////
For i = 4 To 24 Step 5
    tot10 = tot10 + Val(txtcase.Item(i).Text)
Next
lbltot.Item(6).Caption = tot10
'/////////////////////////////////////////
For i = 0 To 24 Step 6
    tot11 = tot11 + Val(txtcase.Item(i).Text)
Next
lbltot.Item(5).Caption = tot11
'/////////////////////////////////////////
For i = 4 To 20 Step 4
    tot12 = tot12 + Val(txtcase.Item(i).Text)
Next
lbltot.Item(11).Caption = tot12

End Sub

Codes Sources

A voir également

Vous n'êtes pas encore membre ?

inscrivez-vous, c'est gratuit et ça prend moins d'une minute !

Les membres obtiennent plus de réponses que les utilisateurs anonymes.

Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.

Le fait d'être membre vous permet d'avoir des options supplémentaires.