' BEGIN ' First we'll create a fake test card dim strCardNum strCardNum = "43130716741528" ' Now we'll use a function (defined below) ' to validate the test card number. boolResult = funcValidateCard (strCardNum) msgBox("Potentially Valid Card Number?" & vbcrlf & vbcrlf & boolResult) ' Finally, here's the function where all ' the work gets done. function funcValidateCard (strCard) dim intCardLength, intSum, intDigit ' first reverse the string strCard = StrReverse(strCard) ' Step through every digit in the number. intCardLength = Len(strCard) i = 1 While i <= intCardLength ' Determine if this is an even space. if i Mod 2 = 0 then ' Double every second space. intWeight = 2 else ' Simply add in odd spaces. intWeight = 1 end if ' Grab the next digit and multiply ' by the weight intDigit = Mid(strCard,i,1) * intWeight ' This bit of magic is equivalent to ' separating the result into digits ' before adding it to our ' running total. intSum = intSum + _ (intDigit Mod 10) + _ Int(intDigit / 10) ' Move to the next digit. i = i + 1 Wend if intSum Mod 10 = 0 then funcValidateCard = true else funcValidateCard = false end if end function ' END