Intergers

1. Junior Member
Join Date
Dec 1969
Posts
5

## Intergers

How do I find out if a variable is a number or a letter? I tried to do<BR><BR>IF variable(int) then<BR>response.write "Variable is a Number"<BR>else<BR>end if

2. Senior Member
Join Date
Dec 1969
Location
Indianapolis, IN
Posts
1,755

## That must be the British spelling... ;-)

Try this:<BR>Isnumeric(myvar)

3. Senior Member
Join Date
Dec 1969
Posts
96,118

## No such thing...

...though there *are* integers. (Sorry...the spelling pedant in me. Only one "r" in the word.)<BR><BR>ANYWAY...<BR><BR>If IsNumeric( variable ) Then<BR> num = CDBL( variable )<BR> If num = Int(num) Then <BR> Response.Write "variable is an integer"<BR> Else<BR> Response.Write "variable is a number but is not an integer"<BR> End If<BR>End If<BR><BR>

4. Senior Member
Join Date
Dec 1969
Posts
96,118

## That doesn't check for integer...

A string such as "0.0000032" will pass the IsNumeric test. Or a string like "1.73E+98" will, also.<BR><BR>

5. Senior Member
Join Date
Dec 1969
Location
Indianapolis, IN
Posts
1,755

## His question stated...

&#062;&#062;How do I find out if a variable is a number or a letter?<BR><BR>Yeah, he had a title of "intergers", but I addressed his actual question.

6. Senior Member
Join Date
Dec 1969
Posts
1,570

## I think he gotcha Bill....

7. Senior Member
Join Date
Dec 1969
Posts
11,334

## Somewhat

He asked "How can I tell a number or a letter?"<BR><BR>Well, if you do <BR><BR>IsNumeric(",")<BR><BR>Returns false... not necessarily a letter. Who knows what he&#039;s really after.

8. Senior Member
Join Date
Dec 1969
Posts
1,570

## I know...

Bill&#039;s answer is actually the efficient way to check for integers successfully. Good answer Bill!!

9. Senior Member
Join Date
Dec 1969
Posts
96,118

## But look at his PROPOSED code...

He tried to write:<BR><BR> IF variable(int) then <BR><BR>clearly attempting to find out if "variable" is an "int" or not.<BR><BR><BR>

10. Senior Member
Join Date
Dec 1969
Posts
96,118