ASP
判断一个字符串是否是数字
for
i
=
1
to
Len
(cNumber)
if not IsNumeric ( Mid (cNumber,i, 1 )) then
isNum = false
response.write( " i: " & i & " -- " & Mid (cNumber,i, 1 ) & " <br> " )
end if
if not isNum then exit for ' 跳出for循环
next
if not IsNumeric ( Mid (cNumber,i, 1 )) then
isNum = false
response.write( " i: " & i & " -- " & Mid (cNumber,i, 1 ) & " <br> " )
end if
if not isNum then exit for ' 跳出for循环
next
判断信用卡号是否有效
function
isCreditCard(cardNo)
isCreditCard = false
lCard = len (cardNo)
lC = right (cardNo, 1 )
cStat = 0
for i = (lCard - 1 ) to 1 step - 1
tempChar = mid (cardNo, i, 1 )
d = cint (tempChar)
if lcard mod 2 = 1 then
temp = d * ( 1 + ((i + 1 ) mod 2 ))
else
temp = d * ( 1 + (i mod 2 ))
end if
if temp < 10 then
cStat = cStat + temp
else
cStat = cStat + temp - 9
end if
next
cStat = ( 10 - (cStat mod 10 )) mod 10
if cint (lC) = cStat then isCreditCard = true
end function
isCreditCard = false
lCard = len (cardNo)
lC = right (cardNo, 1 )
cStat = 0
for i = (lCard - 1 ) to 1 step - 1
tempChar = mid (cardNo, i, 1 )
d = cint (tempChar)
if lcard mod 2 = 1 then
temp = d * ( 1 + ((i + 1 ) mod 2 ))
else
temp = d * ( 1 + (i mod 2 ))
end if
if temp < 10 then
cStat = cStat + temp
else
cStat = cStat + temp - 9
end if
next
cStat = ( 10 - (cStat mod 10 )) mod 10
if cint (lC) = cStat then isCreditCard = true
end function