Hello,im wondering how i can genrate 11 numbers all beggin with 7 example
i click genrate it says in text1 795656532 click again it says 7139900,many thanks
Printable View
Hello,im wondering how i can genrate 11 numbers all beggin with 7 example
i click genrate it says in text1 795656532 click again it says 7139900,many thanks
If you always want large numbers like that you could do it like this:VB Code:
sNum As String Dim i As Integer Dim iMax As Integer Randomize sNum = "7" '<- You wanted it to start with a 7 iMax = Int(Rnd * 4) + 4 '<- iMax will be a number between 4 and 7 For i = 1 To iMax '<- Loop from 1 to (4-7) sNum = sNum & Int(Rnd * 10) Next 'sNum will now be a 5 to 8 digit number starting with a 7 Text1.Text = sNum
i want it to genrate 16 numbers each time, i tried changing iMax = Int(Rnd * 9) + 9 to diffrent things etc,and it genrators ramdom amound of numbers like
769591628176
729741547050
7660505292077
some are longer than overs i just want 16 in total many thanks any ideas?
Sorry, your first post showed two numbers of different lengths so I thought that was what you wanted. Simply skip the iMax line and change the loop to:VB Code:
'Replace iMax with 15 to generate a 16 digit number (with the initial 7) Dim i = 1 To [b]15 [/b]
sNum As String
Dim i As Integer
Dim iMax As Integer
Private Sub Command1_Click()
Randomize
sNum = "7" '<- You wanted it to start with a 7
iMax = Int(Rnd * 4) + 4 '<- iMax will be a number between 4 and 7
For i = 15 To iMax '<- Loop from 1 to (4-7)
Dim i = 1 To 15
sNum = sNum & Int(Rnd * 10)
Next
'sNum will now be a 5 to 8 digit number starting with a 7
Text1.Text = sNum
End Sub
***
Sorry, I accidently typed Dim but I meant For.VB Code:
sNum As String Dim i As Integer Randomize sNum = "7" '<- You wanted it to start with a 7 For i = 1 To 15 sNum = sNum & Int(Rnd * 10) Next 'sNum will now be a 5 to 8 digit number starting with a 7 Text1.Text = sNum