Tuesday, June 29, 2010

How to print the first digit of the numbers

When i input a number, my result omit the first digit and display the remaining numbers ex: if my input is 4321, it should print 4321, 321, 21, 1.

no=4321
While no>=1
msgbox no
noi=len(no)
div=divVal(noi-1)
no=no mod div
Wend

Function divVal(x)
val=1
For i=1 to x
val=val*10
Next
divVal=val
End Function

If you dont bother of type casting, you can also use:
no=cstr("4321")
for i=1 to len(no)
counter=0
msgbox mid(no,i,len(no)-counter)
counter=counter+1
next