If strCardNum.Length <> 5 Then
            MessageBox.Show("Please enter a 5 numbers.", _
                             "Georgetown Credit", _
                             MessageBoxButtons.OK, MessageBoxIcon.Information)
        ElseIf Not (Integer.TryParse(strCardNum.Substring(0, 1), intNum1) _
        OrElse Integer.TryParse(strCardNum.Substring(1, 1), intNum2) _
        OrElse Integer.TryParse(strCardNum.Substring(2, 1), intNum3) _
        OrElse Integer.TryParse(strCardNum.Substring(3, 1), intNum4) _
        OrElse Integer.TryParse(strCardNum.Substring(4, 1), intNum5)) Then
            MessageBox.Show("The card number entered is not number")
        Else
            intSumNum = intNum1 + (intNum2 * 2) + intNum3 + (intNum4 * 2)

            intSumNum = Convert.ToInt32(strSumNum)(it won't accept this, how do I get this part convert?)

            If intNum5.ToString() = (strSumNum.Substring(2, 1)) Then
                Me.lblCreditCard.Text = "The credit card number is valid."
            Else
                Me.lblCreditCard.Text = "The credit card number is invalid."
            End If
        End If

Edited 5 Years Ago by Nick Evan: Added CODE-tags

If strCardNum.Length <> 5 Then
            MessageBox.Show("Please enter a 5 numbers.", _
                             "Georgetown Credit", _
                             MessageBoxButtons.OK, MessageBoxIcon.Information)
        ElseIf Not (Integer.TryParse(strCardNum.Substring(0, 1), intNum1) _
        OrElse Integer.TryParse(strCardNum.Substring(1, 1), intNum2) _
        OrElse Integer.TryParse(strCardNum.Substring(2, 1), intNum3) _
        OrElse Integer.TryParse(strCardNum.Substring(3, 1), intNum4) _
        OrElse Integer.TryParse(strCardNum.Substring(4, 1), intNum5)) Then
            MessageBox.Show("The card number entered is not number")
        Else
            intSumNum = intNum1 + (intNum2 * 2) + intNum3 + (intNum4 * 2)
            strSumNum = Str(intSumNum)


            If intNum5.ToString() = (strSumNum.ToString()).Substring(1)(for some reason, it still show invalid answer...I'm missing something? Error part?) Then
                Me.lblCreditCard.Text = "The credit card number is valid."
            Else
                Me.lblCreditCard.Text = "The credit card number is invalid."
            End If
        End If

Edited 5 Years Ago by Nick Evan: Added CODE-tags

For some reason The "If intNum5.ToString() = (strSumNum.ToString()).Substring(1)" is overloaded and I need to fix that to find the last digit from strSumNum that is matching up to intNum5. How Do I do that?

If strCardNum.Length <> 5 Then
MessageBox.Show("Please enter a 5 numbers.", _
"Georgetown Credit", _
MessageBoxButtons.OK, MessageBoxIcon.Information)
ElseIf Not (Integer.TryParse(strCardNum.Substring(0, 1), intNum1) _
OrElse Integer.TryParse(strCardNum.Substring(1, 1), intNum2) _
OrElse Integer.TryParse(strCardNum.Substring(2, 1), intNum3) _
OrElse Integer.TryParse(strCardNum.Substring(3, 1), intNum4) _
OrElse Integer.TryParse(strCardNum.Substring(4, 1), intNum5)) Then
MessageBox.Show("The card number entered is not number")
Else
intSumNum = intNum1 + (intNum2 * 2) + intNum3 + (intNum4 * 2)
strSumNum = Str(intSumNum)


If intNum5.ToString() = (strSumNum.ToString()).Substring(1)Then
Me.lblCreditCard.Text = "The credit card number is valid."
Else
Me.lblCreditCard.Text = "The credit card number is invalid."
End If
End If

Edited 5 Years Ago by Vikijo: n/a

I need to fix that to find the last digit from strSumNum that is matching up to intNum5. How Do I do that?

You mean that you just want to get the last digit on strSumNum then compared that last digit on intNum1 to intNum5 is that what you're trying to achieve?

i supposed you want the last digit for strSumNum and compare to all, you can use right function to get the last digit, then do a loop to compare. hope this suggestion wil help, but not so familiar with vb.net but we have vb.net forums guys out there should be able to help you a lot.

Edited 5 Years Ago by cguan_77: n/a

I have asked the mods to move this from VB 4/5/6 to VB.Net. I'm sure you will find your solution over there.:)

This article has been dead for over six months. Start a new discussion instead.