rinkydink
asked on
need 0 to always show in text box
num = Int(Rnd * 10) & Int(Rnd * 10) & Int(Rnd * 10) & Int(Rnd * 10) & Int(Rnd * 10)
Text1 = num
with the above code, my 0's do not always appear
i am not sure why
i need five numbers everytime from 0 to 9
any ideas?
thanks for any help
Text1 = num
with the above code, my 0's do not always appear
i am not sure why
i need five numbers everytime from 0 to 9
any ideas?
thanks for any help
Text1 = chr$(Rnd*10+48)+chr$(Rnd*1 0+48)+chr$ (Rnd*10+48 )+chr$(Rnd *10+48)+ch r$(Rnd*10+ 48)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Alternativley just change the line:
Text1 = num
to
Text1 = Format(num,"00000")
Text1 = num
to
Text1 = Format(num,"00000")
Option Explicit
Private Sub Form_Load()
Randomize Timer
End Sub
Private Sub Command1_Click()
' Int((upperbound - lowerbound + 1) * Rnd + lowerbound)
Dim lngNum As Long
Dim strNum
lngNum = CLng((99999 - 0 + 1) * Rnd + 0)
strNum = Format(lngNum, "00000")
Label1.Caption = strNum
End Sub
Private Sub Form_Load()
Randomize Timer
End Sub
Private Sub Command1_Click()
' Int((upperbound - lowerbound + 1) * Rnd + lowerbound)
Dim lngNum As Long
Dim strNum
lngNum = CLng((99999 - 0 + 1) * Rnd + 0)
strNum = Format(lngNum, "00000")
Label1.Caption = strNum
End Sub
ASKER
and it seems like i am always missing 0's at the end of my number
i need them to show so i have a 5 digit number everytime
thanks