nafaught
asked on
EVB code for LUHN Algorithm validation
We are using embedded visual basic to check credit card numbers as they are entered into a text box (called 'edtaccount') on a PPC handheld. The following code works perfectly if I run it in Visual Basic but when I try to compile in EVB it gives me an error on the following lines:
ReDim varArrNo(1 To intLength)
ReDim intArrProd(1 To intLength)
I've attached the code below and am not quite sure why this would compile and work in VB6 but not EVB? Thanks for the help!
ReDim varArrNo(1 To intLength)
ReDim intArrProd(1 To intLength)
I've attached the code below and am not quite sure why this would compile and work in VB6 but not EVB? Thanks for the help!
' nf :: Luhn Algorith (Mod 10) :: validate credit card
' ***************************
Dim txtInput As String, txtOutput As String
Dim intLength As Integer, intL1 As Integer, intDigit As Integer, intTmp As Integer
Dim varArrNo() As Variant, intArrProd() As Integer, intSum As Integer
Dim lngEnum As Long
Dim intModulus As Integer
Dim strRes As String
txtInput = Trim(edtAccount.Text)
intLength = Len(txtInput)
If intLength = 0 Then
Exit Sub
End If
Dim varArrNo(1 To intLength) As Variant
Dim intArrProd(1 To intLength) As Integer
intModulus = 10
intDigit = 2
If Not IsNumeric(Right(txtInput, 1)) Then
MsgBox "Only numeric chars are allowed in Modulus 10", vbInformation, ""
Exit Sub
End If
For intL1 = intLength To 1 Step -1
If intDigit = 1 Then
intDigit = 2
ElseIf intDigit = 2 Then
intDigit = 1
End If
varArrNo(intL1) = Val(Mid(txtInput, intL1, 1))
intArrProd(intL1) = intDigit
intTmp = intDigit * Val(Mid(txtInput, intL1, 1))
If intTmp < 10 Then
intSum = intSum + intTmp
Else
intSum = intSum + Val(Left(intTmp, 1))
intSum = intSum + Val(Right(intTmp, 1))
End If
Next
intDigit = intSum Mod 10
If intDigit = 0 Then
strRes = "Verified"
Else
strRes = "not Verified"
End If
MsgBox strRes
' ***************************
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER