G
Guest
I am using the following code to pick off each digit of a number, from right
to left. The number I am working with is 84357. So for the first iteration it
should return the number 7 and for the second iteration it should return the
number 5, and so on. But for some reason on the first iteration returns the
expected results. Each subsequent iteration returns the number plus 1. In
order words, when I run the program I am getting: 7, 6, 4, and 9. Instead of
7, 5, 3, 4, and 8. Can someone tell me what's wrong with my code?
Sub Main()
Dim input As Integer = 84357
Dim digit As Integer
Dim decimalNumber As Integer
Dim divisor As Integer = 1
While input >= 0
digit = (input / divisor) Mod 10
divisor *= 10
End While
End Sub ' Main
to left. The number I am working with is 84357. So for the first iteration it
should return the number 7 and for the second iteration it should return the
number 5, and so on. But for some reason on the first iteration returns the
expected results. Each subsequent iteration returns the number plus 1. In
order words, when I run the program I am getting: 7, 6, 4, and 9. Instead of
7, 5, 3, 4, and 8. Can someone tell me what's wrong with my code?
Sub Main()
Dim input As Integer = 84357
Dim digit As Integer
Dim decimalNumber As Integer
Dim divisor As Integer = 1
While input >= 0
digit = (input / divisor) Mod 10
divisor *= 10
End While
End Sub ' Main