First of all you should make it clear to yourself what you mean by validate the number. What criterias should be met in order for the number to be valid? (the Danish social secruity numbers must meet a special matematical formula in order to be valid).
This might also help (assume that s contains the social security number):
if isnumeric(left$(s,3)) and mid$(s,4,1)="-" and isnumeric(mid$(s,5,2)) and mid$(s,7,1)="-" and isnumeric(mid$(s,8)) and len (s)=11 then ...
Sunaj
'The gap between theory and practice is not as wide in theory as it is in practice'
If you want to avoid the problem that codefish mentions, you can write your own isnumeric function. Something like (I don't have my VB here, so excuse any errors):
private sub IsNum(TheString as string) as boolean
dim i as long, MyCharAsc as string*1
for i = 1 to len(TheString)
MyCharAsc = asc(mid$(TheString,i,1))
if MyChar<48 or MyChar>58 then IsNum=false:exit function
next i
isnum=true
end sub
Sunaj
'The gap between theory and practice is not as wide in theory as it is in practice'
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.