02-27-2006, 06:38 AM
I've always been under the impression that in QuickBasic you could compare numeric strings, with or without leading zeros.
In this particular case, I was making sure that the input string would fit into an integer. The string had already been checked to make sure that all the digits were numeric. Example:
The above works fine as long as x$ does not contain any leading zeros. For example, if x$ contains "032768" or "0099999" then the above IF statement does not print the error message.
However, if you do the following, it works fine:
WHY?
*****
In this particular case, I was making sure that the input string would fit into an integer. The string had already been checked to make sure that all the digits were numeric. Example:
Code:
rem ... x$ is the string containing the input numeric digits.
if x$ > "32767" the print "Error: number is not an integer"
However, if you do the following, it works fine:
Code:
rem ... x$ is the string containing the input numeric digits.
dim d as double
d = val(x$)
if d > 32767 the print "Error: number is not an integer"
WHY?
*****