|
-
Aug 30th, 2000, 06:35 AM
#1
Thread Starter
Hyperactive Member
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!
-
Aug 30th, 2000, 06:42 AM
#2
transcendental analytic
Yep, youre correct
Code:
For x=0 to randomnumber-1
if temp>0 then temp =temp & ","
temp=temp & randomnumber
next x
label=temp
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Aug 30th, 2000, 06:44 AM
#3
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!
-
Aug 30th, 2000, 06:45 AM
#4
Fanatic Member
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
VB6 sp5, SQL Server 2000, C#
There are no stupid questions. Only stupid people. 
-
Aug 30th, 2000, 06:46 AM
#5
New Member
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
Give me five lines written by the most honourable of men, and I shall find in them an excuse to hang him. - Cardinal Richelieu
Ben Stappleton
VB6E SP4
-
Aug 30th, 2000, 07:14 AM
#6
Thread Starter
Hyperactive Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|