Hi All,
Is there any way of reading the individual digits from a number into separate variables, for instance if the variable ‘Number = 54321’ could I copy it to 5 variables called digit1, digit2, digit3 etc with each one containing a single digit.
So I would have
digit1 = 5
digit2 = 4 etc
I have tried using strings, my mess of a calculation is below but I just end up with an empty string.
____
SplitNumber = left$ (Number,1)
Digit1 = StringToInt$ (SplitNumber)
____
Please help
Thanks
Ben
Help with reading single digits from a number
Moderator: Benj
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: Help with reading single digits from a number
Hi Ben,
You can easily achieve that with the MOD function: Let me know I you would prefer to use a string rather than Int or UIint and I can help you further.
Martin
You can easily achieve that with the MOD function: Let me know I you would prefer to use a string rather than Int or UIint and I can help you further.
Martin
Martin
-
- Posts: 37
- Joined: Tue May 14, 2013 8:18 pm
- Has thanked: 6 times
- Been thanked: 1 time
- Contact:
Re: Help with reading single digits from a number
That does exactly what I wanted, thank you so much.
Ben
Ben
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: Help with reading single digits from a number
Your welcome,
Glad its what your after.
Thanks for letting us know
Glad its what your after.
Thanks for letting us know
Martin