Finding the type of a variable

Results 1 to 2 of 2

Thread: Finding the type of a variable

  1. #1
    Join Date
    Dec 1969

    Default Finding the type of a variable

    Hi,<BR><BR>I&#039;m trying to write a simple postcode matching app, which takes the first two characters of the postcode and matches it against a database record.<BR><BR>The problem i&#039;m having is that because the first two characters can be different types i can&#039;t fatham out how to work out what they are.<BR><BR>e.g. LL or L3<BR><BR>I need to be able to say, If the 2nd character is a number then only search for an exact match on the 1st letter, or if the 2nd letter is a letter then search for an exact match on the first and second letters together.<BR><BR>I&#039;ve tried using the VarType function on the second character but it returns a type of 8 instead of 2 even if i know it&#039;s a number.<BR><BR>Many thanks,<BR><BR>Robert

  2. #2
    Join Date
    Dec 1969

    Default RE: Finding the type of a variable

    No, it&#039;s a string. Or that&#039;s what I&#039;m betting.<BR><BR>Dim strChar1: strChar1 = Left(strPostcode, 1)<BR>Dim strChar2: strChar2 = Mid(strPostcode, 2, 1)<BR><BR>If IsNumeric(strChar2) then<BR> &#039; Blah<BR>Else<BR> &#039; Blah<BR>End If<BR><BR>By the way, if you take the second character using any string-handling functions (left/right/mid, etc), then it will be a STRING, unless you convert it. Which is why you&#039;re getting 8 instead of 2.<BR><BR>Craig.

Posting Permissions

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