For eg. you need to type in yr IC number(pls enter yr IC number[,must be 6 digit.]: 045234)
when writing program,we need to show an error msg if the user doesn't key in 6 digit like 09877.so how to check whether the number key in is 6 digit or not?
How to check whether the no. you key in is 6 digit or not in visual C++?use array?how to use?
Why not assign the number to a string? That way you can do a .length of .size and check that against 6 to see if it matches.
Example
dim sixDigitKey as string
dim keyLength as int
keyLength = sixDigitKey.length
if keyLength = 6
{
do this
}
else
{
do this
}
The only way this would be a problem is if you need to use the key as a number. It's a little more trickier to convert a string to a number.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment