Today, we are going to make a Credit Card Determiner in VB.NET.
First if all open your Visual Studio or Visual Basic, create a new Project, add two text boxes & a button, change the button text property to check or whatever you want.
I recommend you to set your tools like this
First if all open your Visual Studio or Visual Basic, create a new Project, add two text boxes & a button, change the button text property to check or whatever you want.
I recommend you to set your tools like this
Public Class form1
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
If Asc(e.KeyChar) <> 13 AndAlso Asc(e.KeyChar) <> 8 _
AndAlso Not IsNumeric(e.KeyChar) Then
MessageBox.Show("Please Enter Numbers Only")
e.Handled = True
End If
End Sub
Public Sub visa()
TextBox1.SelectionStart = (0)
TextBox1.SelectionLength = (1)
If TextBox1.SelectedText = 4 And TextBox1.Text.Length = 16 Then
TextBox2.Text = " Visa Card"
Else
mastercard()
End If
End Sub
Public Sub mastercard()
TextBox1.SelectionStart = (0)
TextBox1.SelectionLength = (2)
If TextBox1.SelectedText = 51 And TextBox1.Text.Length = 16 Then
TextBox2.Text = " MasterCard"
ElseIf TextBox1.SelectedText = 52 And TextBox1.Text.Length = 16 Then
TextBox2.Text = " MasterCard"
ElseIf TextBox1.SelectedText = 53 And TextBox1.Text.Length = 16 Then
TextBox2.Text = " MasterCard"
ElseIf TextBox1.SelectedText = 54 And TextBox1.Text.Length = 16 Then
TextBox2.Text = " MasterCard"
ElseIf TextBox1.SelectedText = 55 And TextBox1.Text.Length = 16 Then
TextBox2.Text = " MasterCard"
Else
americanexpress()
End If
End Sub
Public Sub americanexpress()
TextBox1.SelectionStart = (0)
TextBox1.SelectionLength = (2)
If TextBox1.SelectedText = 34 And TextBox1.Text.Length = 15 Then
TextBox2.Text = "American Express"
ElseIf TextBox1.SelectedText = 35 And TextBox1.Text.Length = 15 Then
TextBox2.Text = "American Express"
ElseIf TextBox1.SelectedText = 36 And TextBox1.Text.Length = 15 Then
TextBox2.Text = "American Express"
ElseIf TextBox1.SelectedText = 37 And TextBox1.Text.Length = 15 Then
TextBox2.Text = " American Express"
Else
diners1()
End If
End Sub
Public Sub diners1()
TextBox1.SelectionStart = (0)
TextBox1.SelectionLength = (3)
If TextBox1.SelectedText = 300 And TextBox1.Text.Length = 14 Then
TextBox2.Text = " Diners Club"
ElseIf TextBox1.SelectedText = 301 And TextBox1.Text.Length = 14 Then
TextBox2.Text = " Diners Club"
ElseIf TextBox1.SelectedText = 302 And TextBox1.Text.Length = 14 Then
TextBox2.Text = " Diners Club"
ElseIf TextBox1.SelectedText = 303 And TextBox1.Text.Length = 14 Then
TextBox2.Text = " Diners Club"
ElseIf TextBox1.SelectedText = 304 And TextBox1.Text.Length = 14 Then
TextBox2.Text = " Diners Club"
ElseIf TextBox1.SelectedText = 305 And TextBox1.Text.Length = 14 Then
TextBox2.Text = " Diners Club"
Else
diners2()
End If
End Sub
Public Sub diners2()
TextBox1.SelectionStart = (0)
TextBox1.SelectionLength = (2)
If TextBox1.SelectedText = 36 And TextBox1.Text.Length = 14 Then
TextBox2.Text = " Diners Club"
ElseIf TextBox1.SelectedText = 38 And TextBox1.Text.Length = 14 Then
TextBox2.Text = " Diners Club"
Else
discover1()
End If
End Sub
Public Sub discover1()
TextBox1.SelectionStart = (0)
TextBox1.SelectionLength = (4)
If TextBox1.SelectedText = 6011 And TextBox1.Text.Length = 16 Then
TextBox2.Text = " Discover Card"
Else
discover2()
End If
End Sub
Public Sub discover2()
TextBox1.SelectionStart = (0)
TextBox1.SelectionLength = (2)
If TextBox1.SelectedText = 65 And TextBox1.Text.Length = 16 Then
TextBox2.Text = " Discover Card"
Else
TextBox2.Text = "Unknown Card"
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If TextBox1.Text = "" Then
Else
mastercard()
discover1()
discover2()
diners1()
diners2()
americanexpress()
visa()
End If
End Sub
End Class


2 comments
no visa, mastero?
Replyit has visa and mastercard
ReplyPost a Comment
Note: Only a member of this blog may post a comment.