This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallShield
- :
- InstallShield Forum
- :
- Check string contains number between 0-9
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jul 24, 2013
07:03 AM
Check string contains number between 0-9
I writing in installscript and looking for a simply way to check if string contains number between 0-9.
Thanks in advance....
Thanks in advance....
(2) Replies
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jul 24, 2013
08:15 AM
If you know that the string is a string representation of a number (and does not include none number characters) then use StrToNum() to convert the string to a number and thest the value of the number. See:
http://kb.flexerasoftware.com/doc/Helpnet/installshield16helplib/mergedProjects/installshield16langref/LangrefStrToNum_example.htm
StrToNum(nNumber, szString);
if (nNumber > 0 && nNumber < 9) then
..do something
endif;
If the string has none number characters and you can divide the string into a substring, then do that first to isolate the number to a string, and take the above approach.
If the string is random characters which you cannot isolate into a substring of numbers, then I guess you would need to test for each numeric character in the range of concern.
szString = "asgeag4asdgga"
if (szString % "4") then
..includes a "5" character
elseif (szString % "5") then
..includes a "5" character
elseif ((szString % "4") || (szString % "5")) then
..includes either 4 or 5 characters
endif
http://kb.flexerasoftware.com/doc/Helpnet/installshield16helplib/mergedProjects/installshield16langref/LangrefStrToNum_example.htm
StrToNum(nNumber, szString);
if (nNumber > 0 && nNumber < 9) then
..do something
endif;
If the string has none number characters and you can divide the string into a substring, then do that first to isolate the number to a string, and take the above approach.
If the string is random characters which you cannot isolate into a substring of numbers, then I guess you would need to test for each numeric character in the range of concern.
szString = "asgeag4asdgga"
if (szString % "4") then
..includes a "5" character
elseif (szString % "5") then
..includes a "5" character
elseif ((szString % "4") || (szString % "5")) then
..includes either 4 or 5 characters
endif
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jul 24, 2013
09:47 AM
Hi,
Thanks for your replay.
StrToNum is good enought.
But the problem that you look for a number between 0 and 9
I can get a number like 20000
And want to check if it contains number in it vs contains Alphabets or something like that.
Thanks in advance...
Thanks for your replay.
StrToNum is good enought.
But the problem that you look for a number between 0 and 9
I can get a number like 20000
And want to check if it contains number in it vs contains Alphabets or something like that.
Thanks in advance...