I have written a method to take an integer and convert it to either decimal, hex, or binary depending on what you choose using commenting. I will build a choice in later. The problem I am having is that the wrong values are being chosen and I think it has to do with the modulus operator returning the wrong value. It may be a rounding issue because I always seem to be off by 1 digit, but not for every char in the string. Any help would be appreciated. For example, right now it is set up give the decimal value. So if you run this and enter 1705, it should return 1705, but instead it returns 2705. Hex and Binary are not much better.
Do While val >= 1 'finds the remainder and assigns it array
r = val Mod base
buf(i) = arr(r)
'Possible rounding issue:
val = val / base 'need whole number division to find val.
i = i - 1 'decrement the buf array
Loop