checking for integer or letters

Results 1 to 2 of 2

Thread: checking for integer or letters

  1. #1
    Join Date
    Dec 1969

    Default checking for integer or letters

    Using request.querystring I am getting information from a http header what I am looking to tell from that whether it is a integer or a series of letters. How would I check for that? Thanks

  2. #2
    Join Date
    Dec 1969

    Default What about mixed numbers and letters?

    Or symbols? Or...<BR><BR>Anyway, assuming you really only care about "Is this a valid number or not?" then...<BR><BR>&#060;%<BR>Qval = Request.QueryString("whateverName")<BR><BR>val = "#" &#039 any string works...<BR>On Error Resume Next<BR>val = CLng( Qval ) &#039 I use CLng because CInt can&#039t handle &#062; 32767<BR>On Error GoTo 0<BR><BR>&#039 at this point, if Qval is a valid integer, then val will have the value.<BR>&#039 If not, val will still contain "#"<BR><BR>If val = "#" Then<BR> &nbsp; ... not an integer ...<BR>Else<BR> &nbsp. ... val is ready to use ...<BR>End If<BR>%&#062;<BR><BR>You can also use the VBS function "isNumeric", but it allows floating point numbers as well as integers...and even after you know the value is a number you don&#039t know what its numeric value is, so you still have to use CLng. Why not do it all in one step?<BR><BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts