-
I was thinking about this for a while, thought I could do it, but then realised that I could be thinking about it all day and mightn't even acheive it.
I have a button on my form:
Private Sub Command1_Click()
dim randomnumber as integer
randomnumber = Int(rnd * 10) + 2
end sub
This generates a random number from 2 to 11
Then I have another button, command2.
When I click this I want the series of numbers, starting at 0 and ending at the number before randomnumber, to be printed in my label1.
For example:
randomnumber = 7
In label1 will be printed: 0,1,2,3,4,5,6
Does anybody have any code as to how this could be done. I bet you it's something like For x = 0 to randomnumber blah, blah, but I don't know much about that.
Thanks!
-
Yep, youre correct
Code:
For x=0 to randomnumber-1
if temp>0 then temp =temp & ","
temp=temp & randomnumber
next x
label=temp
-
Your right! It has something to do with For...Next:
Code:
'assuming all variables is declared allready
For i = 0 To randomnumber - 1
strTemp = strTemp & i & ", "
Next
'remove the last comma+space and asign to the Label
Label1 = Left$(strTemp, Len(strTemp - 2))
Good luck!
-
Code:
Dim intCount as Integer
Label1.Caption = ""
For intCount = 0 To RandomNumber - 1
Label1.Caption = Label1.Caption & intCount
If intCount <> RandomNumber - 1 Then Label1.Caption = Label1.Caption & ","
Next intCount
-
for x=0 to (randomnumber - 1)
if x <> (randomnumber - 1) then
label1.caption = label1.caption & x & ","
else
label1.caption = label1.caption & x
end if
next x
-