I can't seem to get the right solution. Can anyone add or give me some advice on this solution.
CODE
Dim creditNum 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
creditNum = Me.xNumberTextBox.Text
' verify that the credit card number contains five digits
If creditNum Like "#####" Then
' calculate correct check digit
Integer.TryParse(creditNum.Substring(0, 1), num1)
Integer.TryParse(creditNum.Substring(1, 1), num2)
Integer.TryParse(creditNum.Substring(2, 1), num3)
Integer.TryParse(creditNum.Substring(3, 1), num4)
'calculate sum of digit
sumOfDigits = num1 + num2 + num3 + num4
'calculate check digit
creditNum = "#####"
num1 = num1
num2 = num1 * 2
num3 = num2
num4 = num3 * 2
checkDigit = CStr(sumOfDigits)
' determine whether the credit card number ends with the correct check digit
If creditNum.EndsWith(checkDigit) 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