-
Hi,
I have a program with six text boxes and a few of these relate to one another ie. data entered changes the data in the other after a calculation. The problem I am having is that if I display a negative num or decimal or nothing...I get an error.
I tried some code that checks to see if it is a number before doing the calc but it didn't check for decimals and negative numbers.
Can anyone please help with how to do this.
Thanks in advance,
Scott
-
Here are two functions that will check the numbers
public Function CheckNeg(vValue as single) as boolean
if abs(vvalue)=vvalue then
CheckNeg=false
else
CheckNeg=true
end if
End Function
Public Function CheckDecimal(vValue as single) as boolean
if Int(vValue)=vvalue then
CheckDecimal=False
else
CheckDecimal=True
end if
End Function
These Functios will both return false if the number is OK, else they will return True if the number is a decimal or negative
PS If you use singles instead of Integers or Longs then unless you are doing square roots then you shouldn't get many errors