Simple One.....

Results 1 to 4 of 4

Thread: Simple One.....

  1. #1
    Grommit Guest

    Default Simple One.....

    I&#039ve got a string (searchval) that could contain either a 2 digit number or a query string of unknown length. How do I check the value of the string?<BR><BR>If Len(searchval) = 2 AND [only contains numbers] Then<BR> abc<BR>Else<BR> xyz<BR>End If<BR><BR>Thanks...

  2. #2
    Join Date
    Dec 1969

    Default IsNumeric should work.....

    If Len(searchval) = 2 AND isNumeric(searchVal) Then<BR>&nbsp; &nbsp; val = CInt(searchVal)<BR>Else<BR>&nbsp; &nbsp; xyz<BR>End If<BR>

  3. #3
    Join Date
    Dec 1969

    Default RE: Simple One.....

    Use IsNumeric()function

  4. #4
    SPG Guest

    Default Not trusting isNumeric()...

    ... you could have a regular expression check it.<BR><BR>if isWhatIWant(searchVal) ...<BR><BR>function isWhatIWant(strIn)<BR> dim objRE<BR> set objRE = new RegExp<BR> RegExp.pattern = "^dd$"<BR> if regExp.test(strIn) then<BR> isWhatIWant = true<BR> else<BR> isWhatIWant = false<BR> end if<BR>end function<BR><BR>(I&#039m not positive about the ^dd$ -- the ^ and the $ (beginning and end of line markers) may be reversed; I do that a lot -- but the dd checks for the existence of two digits.)

Posting Permissions

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