Is it numeric?

nuttychick

Registered User.
Local time
Today, 08:12
Joined
Jan 16, 2004
Messages
84
What to do something that I initally thought would be easy to find out..no such luck!

The code is below and works fine, however I only want the first If to run if the start of the fesibility_code is "0" AND the second digit is not a numeric one.
i.e. Run only if the code is 0AB or 0BB etc. Don't run if the code is 07AA etc.

I have highlighted in red where I need to put this.. but dont know what to use. Is it not going to be as simple as I first thought?

Please can someone help! Thank you!:)

Code:
    MySet.MoveFirst
    If Mid(MySet!Feasibility_code, 1, 1) = "0" And 
    Mid(MySet!Feasibility_code, 1, 2) <> [COLOR="Red"]1 - 9[/COLOR] Then
        Prefix = Mid(MySet!Feasibility_code, 1, 1)
        Suffix1Num = Asc(Mid(MySet!Feasibility_code, 2, 1)) - 64
        Suffix2Num = Asc(Mid(MySet!Feasibility_code, 3, 1)) - 63
    Else
        Prefix = Mid(MySet!Feasibility_code, 1, 2)
        Suffix1Num = Asc(Mid(MySet!Feasibility_code, 3, 1)) - 64
        Suffix2Num = Asc(Mid(MySet!Feasibility_code, 4, 1)) - 63
   End If
 
I would probably create a custom function to check if the variable was a number. Something like this


function IsNumber(Var)as Boolean

dim strVar as string

strVar=Var

Select case StrVar

Case ="1"
IsNumber=True
Case="2"
IsNumber=True
Case="3"
IsNumber=True
Case="4"
IsNumber=True
Case="5"
IsNumber=True
Case="6"
IsNumber=True
Case="7"
IsNumber=True
Case="8"
IsNumber=True
Case="9"
IsNumber=True
Case="0"
IsNumber=True
Case else
IsNumber=False
End Select

End Function
 
the instrinsic function
isnumeric()
does the same??

BTW your original question seems to ignore the 00xxxxx possibility - maybe you want it that way.
both KeithG's function (as posted) and the instrinsic will treat the 0 as numeric

izy
 
Sorted thanks!

:D Thank you both,

Have implemented Izyriders suggest (took the less typing option!)

For those interested my code ended up like this.

Code:
If Mid(MySet!Feasibility_code, 1, 1) = "0" 
And Not isNumeric (Mid(MySet!Feasibility_code, 1, 2)) Then

Works like a dream, once again much appreciation and thanks go to the forum and everyone in it!
 

Users who are viewing this thread

Back
Top Bottom