TestNum                                                                                                  Function

 

TESTNUM(theString as string, SignOption as string, NoDigitsBeforeDecPt as integer, NoDigitsAfterDecPt as integer)

 

Description

Tests a string variable's contents to see if :

1. The string represents a valid numeric number.

2. If SignOption is " "(blank) then the string must not have a leading + or – sign. If SignOption is "+" or "-" then a leading + or – sign is allowed.

3. The number of numeric digits in the string appearing before the decimal point cannot exceed NoDigitsBeforeDecPt.

4. The number of numeric digits in the string appearing after the decimal point cannot exceed NoDigitsAfterDecPt.

 

Returns 0 if all tests are met successfully or a non-zero if tests fail.

 

Example

Dim result as integer

Dim temp as string

 

Temp=fldVoltageLevel.text 'picks the string from the field object

 

'the following test allows a + or – string and 3 digits before decimal point

' and 2 digits after the decimal point

If Not TestNum(temp, "-" , 3, 2)=0 then

  Msgbox "The voltage has been entered incorrectly"

End if