I need help to convert a string to an integer or the other way around. I'm trying to use an IF> statement to evaluate the data I have in a text file to something it grabs from the clipboard to compare. It always fails to compare the two and tell me when it has found a match.
Any help would be apprieciated.
converting a string to an integer or integer to string
Moderators: JRL, Dorian (MJT support)
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Actually you don't need to convert numbers to strings or strings to numbers - Macro Scheduler can do that automatically. As long as a string can be interpreted as a number you do not need to do any conversion.
If your comparison fails then it may be that there are spaces or other invisible characters before or after your string.
E.g. "2.5" is numeric, but " 2.5 " is not.
So you could try the following after reading from the file:
VBSTART
VBEND
StringReplace>ValueFromFile,CR,,ValueFromFile
StringReplace>ValueFromFile,LF,,ValueFromFile
StringReplace>ValueFromFile,","",ValueFromFile
VBEval>Trim("%ValueFromFile%"),ValueFromFile
That will remove any carriage returns, line feeds and spaces from the value returned. If a pure number is all that is left then you can now use the numerical comparisons, or mathematical functions.
If your comparison fails then it may be that there are spaces or other invisible characters before or after your string.
E.g. "2.5" is numeric, but " 2.5 " is not.
So you could try the following after reading from the file:
VBSTART
VBEND
StringReplace>ValueFromFile,CR,,ValueFromFile
StringReplace>ValueFromFile,LF,,ValueFromFile
StringReplace>ValueFromFile,","",ValueFromFile
VBEval>Trim("%ValueFromFile%"),ValueFromFile
That will remove any carriage returns, line feeds and spaces from the value returned. If a pure number is all that is left then you can now use the numerical comparisons, or mathematical functions.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?