Pour verifier les numeros de carte bancaire

3/5 (7 avis)

Vue 32 242 fois - Téléchargée 1 747 fois

Description

Ce prog verifie que le numero de carte saisie est valide. Il n'y a rien de pirate puisque tous les sites marchands utilisent un systeme comme celui ci.

Source / Exemple :


Private Sub Command1_Click()
Dim n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12, n13, n14, n15, n16 As Integer
If Text1.Text <> "" Or Text2.Text <> "" Or Text3.Text <> "" Then
On Error GoTo suite
n1 = Mid(Text1.Text, 1, 1) * 2
n2 = Mid(Text1.Text, 2, 1)
n3 = Mid(Text1.Text, 3, 1) * 2
n4 = Mid(Text1.Text, 4, 1)

n5 = Mid(Text2.Text, 1, 1) * 2
n6 = Mid(Text2.Text, 2, 1)
n7 = Mid(Text2.Text, 3, 1) * 2
n8 = Mid(Text2.Text, 4, 1)

n9 = Mid(Text3.Text, 1, 1) * 2
n10 = Mid(Text3.Text, 2, 1)
n11 = Mid(Text3.Text, 3, 1) * 2
n12 = Mid(Text3.Text, 4, 1)

n13 = Mid(Text4.Text, 1, 1) * 2
n14 = Mid(Text4.Text, 2, 1)
n15 = Mid(Text4.Text, 3, 1) * 2
n16 = Mid(Text4.Text, 4, 1)

If n1 >= 10 Then n1 = n1 - 9
If n2 >= 10 Then n2 = n2 - 9
If n3 >= 10 Then n3 = n3 - 9
If n4 >= 10 Then n4 = n4 - 9
If n5 >= 10 Then n5 = n5 - 9
If n6 >= 10 Then n6 = n6 - 9
If n7 >= 10 Then n7 = n7 - 9
If n8 >= 10 Then n8 = n8 - 9
If n9 >= 10 Then n9 = n9 - 9
If n10 >= 10 Then n10 = n10 - 9
If n11 >= 10 Then n11 = n11 - 9
If n12 >= 10 Then n12 = n12 - 9
If n13 >= 10 Then n13 = n13 - 9
If n14 >= 10 Then n14 = n14 - 9
If n15 >= 10 Then n15 = n15 - 9
If n16 >= 10 Then n16 = n16 - 9
total = n1 + n2 + n3 + n4 + n5 + n6 + n7 + n8 + n9 + n10 + n11 + n12 + n13 + n14 + n15 + n16
div = Right$(total, 1)
If div = 0 Then
MsgBox "(" & total & ") Numero correct", vbOKOnly + vbInformation
Else
MsgBox "(" & total & ") Mauvais numero", vbOKOnly + vbExclamation
End If
Else
GoTo suite
End If
suite:
End Sub

Private Sub Text1_Change()
If Len(Text1.Text) = 4 Then Text2.SetFocus
End Sub

Private Sub Text2_Change()
If Len(Text2.Text) = 4 Then Text3.SetFocus
End Sub

Private Sub Text3_Change()
If Len(Text3.Text) = 4 Then Text4.SetFocus
End Sub

Conclusion :


Il y a 4 boite à texte et un boutton, rien de plus simple.

Codes Sources

A voir également

Ajouter un commentaire Commentaires
yoman64 Messages postés 962 Date d'inscription samedi 19 janvier 2002 Statut Membre Dernière intervention 2 août 2010 1
6 juin 2002 à 17:58
Sa sert a koi rien de plus inutile pour un prog vb ptete bon pour une page dhtml
NeoFO Messages postés 30 Date d'inscription mardi 17 octobre 2000 Statut Membre Dernière intervention 18 juin 2002
6 juin 2002 à 18:02
Sa sert pour les commerçant (hôtel apr exemple ) qui recoivent des numeros de carte bancaire par téléphones et il faut verifier si ils sont correct.
Je pense avoir répondu à ta question meme si ça n'en n'était pas une.
Robinwood01 Messages postés 153 Date d'inscription jeudi 25 avril 2002 Statut Membre Dernière intervention 3 juillet 2014
7 juin 2002 à 08:01
Pas mal du tout ... Mais change ca :
Private Sub Text1_Change()
If Len(Text1.Text) = 4 Then Text2.SetFocus
End Sub

Private Sub Text2_Change()
If Len(Text2.Text) = 4 Then Text3.SetFocus
If Len(Text2.Text) = 0 Then Text1.SetFocus
End Sub

Private Sub Text3_Change()
If Len(Text3.Text) = 4 Then Text4.SetFocus
If Len(Text3.Text) = 0 Then Text2.SetFocus
End Sub

Private Sub Text4_Change()
If Len(Text4.Text) = 0 Then Text3.SetFocus
End Sub

Pour que lorsque l'on c'est trompé on ne sois pas obligé de remprendre la souris ou de faire alt + tab.

http://www.robisoft.fr.st (Prog SMS, JPG, Install)
NeoFO Messages postés 30 Date d'inscription mardi 17 octobre 2000 Statut Membre Dernière intervention 18 juin 2002
7 juin 2002 à 08:48
Bonne idée, je n'y avais pas pensé.
Merci
apxa Messages postés 188 Date d'inscription mercredi 15 mai 2002 Statut Membre Dernière intervention 25 avril 2009
7 juin 2002 à 10:23
tiens voila une maniere plus courte pour t'a verification :)

/** POUR VB .NET **/
Private Function verifcode(ByVal numCB As String) As Boolean
Dim result As Boolean
result = False
If numCB.Length = 16 Then
Dim nb1 As Integer
Dim nb2 As Integer
Dim tmp As Integer
nb1 = 0
nb2 = 0
For cnt = 1 To 16
tmp = CInt(Val(Mid$(numCB, cnt, 1)))
If ((cnt - 1) Mod 2) = 0 Then
If (tmp * 2) > 9 Then
nb1 = nb1 + 1 + ((tmp * 2) - 10)
Else
nb1 = nb1 + (tmp * 2)
End If
Else
nb2 = nb2 + tmp
End If
Next cnt
If Not ((nb1 + nb2) 0) And ((nb1 + nb2) Mod 10) 0 Then
result = True
End If
Catch e As Exception
End Try
End If
verifcode = result
End Function

/** POUR VB 6 **/
Private Function verifcode(ByVal numCB As String) As Boolean
Dim result As Boolean
result = False
If Len(numCB) = 16 Then
Dim nb1 As Integer
Dim nb2 As Integer
Dim tmp As Integer
nb1 = 0
nb2 = 0
For cnt = 1 To 16
tmp = CInt(Val(Mid$(numCB, cnt, 1)))
If ((cnt - 1) Mod 2) = 0 Then
If (tmp * 2) > 9 Then
nb1 = nb1 + 1 + ((tmp * 2) - 10)
Else
nb1 = nb1 + (tmp * 2)
End If
Else
nb2 = nb2 + tmp
End If
Next cnt
If Not ((nb1 + nb2) 0) And ((nb1 + nb2) Mod 10) 0 Then
result = True
End If
End If
verifcode = result
End Function

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.