I actually got it to work using this code but you were very helpful in getting me to focus on where the issue was. I was not realizing that using a single character for the checksum reduces the numbers you can use for the first 4 characters. Your first 4 characters would be mostly #s less than 4.
Thanks every one , you were very helpful. I hope that I can be equally as helpful soon.
CODE
Option Explicit On
Option Strict On
Public Class MainForm
Private Sub xExitButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles xExitButton.Click
Me.Close()
End Sub
Private Sub xNumberTextBox_Enter(ByVal sender As Object, ByVal e As System.EventArgs) Handles xNumberTextBox.Enter
Me.xNumberTextBox.SelectAll()
End Sub
Private Sub xNumberTextBox_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles xNumberTextBox.TextChanged
Me.xMessageLabel.Text = String.Empty
End Sub
Private Sub xVerifyButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles xVerifyButton.Click
' get a 5-digit number from the user
Dim cardNum As String
'Dim checkDigit As String
Dim sumOfDigits As Integer
Dim num1 As Integer
Dim num2 As Integer
Dim num3 As Integer
Dim num4 As Integer
Dim num5 As Integer
cardNum = Me.xNumberTextBox.Text
' verify that the credit card number contains five digits
If cardNum Like "#####" Then
' calculate correct check digit
Integer.TryParse(cardNum.Substring(0, 1), num1)
Integer.TryParse(cardNum.Substring(1, 1), num2)
Integer.TryParse(cardNum.Substring(2, 1), num3)
Integer.TryParse(cardNum.Substring(3, 1), num4)
Integer.TryParse(cardNum.Substring(4, 1), num5)
'calculate sum of digit
sumOfDigits = num1 + num2 + num3 + num4
' determine whether the credit card number ends with the correct check digit
If num5 = sumOfDigits Then
' processed when the credit card is valid
Me.xMessageLabel.Text = "The credit card number is valid."
Else
' processed when the credit card is not valid
Me.xMessageLabel.Text = "The credit card number is not valid."
End If
Else ' processed when the user does not enter five digits
MessageBox.Show("Please enter a five-digit number.", "Georgetown Credit", _
MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
Me.xNumberTextBox.Focus()
End Sub
End Class