From: hugoliang on
Dear All,
         How can I know a string only includes number(0,1,...9). Except to judge one character by one character.
         And How to judge it is an integer not a decimal fraction.
         Is there a vi to do it?
         Thanks for any suggestion.
 
 
Hugo
From: GerdW on
Hi Hugo,well, the difference between integer and fractional numbers is the decimal separator sign (either "." or ",", depending on location/OS setting). As you are testing for "only includes numbers" this is already given in the test...To test full strings for numbers you can use this:<img src="http://forums.ni.com/attachments/ni/170/333128/1/TestNumbers.png">The string is converted to U8 array and tested for "In Range" of all chars in the string... Message Edited by GerdW on 06-19-2008 12:45 PM


TestNumbers.png:
http://forums.ni.com/attachments/ni/170/333128/1/TestNumbers.png
From: Mythilt on
One question since you asked about decimal vs fraction.&nbsp; Do you want fractional values to be considered numbers?&nbsp; Many people forget that '.' (or ',' for some countries) is a character as well when they look to see if a string is a number.&nbsp; If you want fractionals to be considered a number, you will have to account for the separator.
From: JoeLabView on
The way I do it is to convert everything to ASCII and scan for the range of numbers as shown in the example, and also look for the period and comma.&nbsp; That covers all angles.&nbsp;
RayR
From: JoeLabView on
As shown in this example:
<img src="http://forums.ni.com/attachments/ni/170/333202/1/numberCheck.PNG"> Message Edited by JoeLabView on 06-19-2008 09:24 AM


numberCheck.PNG:
http://forums.ni.com/attachments/ni/170/333202/1/numberCheck.PNG