|
-
Apr 5th, 2000, 05:37 PM
#1
Thread Starter
Lively Member
Hi,
I have a form. On my form I have 2 labels - label1 and label2.
When my form loads, I use the following code to have it so that label2 is always 1 less than label1:
Private Sub Form_Load()
Randomize
Label1 = Int(Rnd * 10) + 1
Label2 = Val(Label1) - 1
End Sub
But this isn't exactly what I'm trying to acheive. I want label2 to also be a random number. That is, each time the form loads, it will either be 1 less or 1 higher than label1.
For example, If Label1 is 6, Label2 might be 5 or 7.
Could someone please help me to do this?
Thanks.
-
Apr 5th, 2000, 06:14 PM
#2
Junior Member
The answer is quite easy...
Just create variable that will contain a random number (in the range of 0 to 1) which means that the number will be either 1 or 0. If the number is 0 then label2 is label1-1 and if the number is 1 then label2 is label1+1
"He who laughs at a question is not worth being asked"
RavenCrow

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
|