- 'Required to tell the script to make a random number
-
Public Function Rand(ByVal Low As Long, ByVal High As Long) As Long
-
Rand = Int((High - Low + 1) * Rnd) + Low
-
End Function
-
-
Private Sub Command1_Click()
-
-
Dim random_number As Integer
-
Randomize 'Declair Random
-
random_number = Rand(1, 6) 'Generates random number from (Lowest, Highest)
-
-
Select Case random_number 'Sets the value that will change in the Cases
-
Case Is = 1
-
Label1.Caption = "Job One"
-
Case Is = 2
-
Label1.Caption = "Job Two"
-
Case Is = 3
-
Label1.Caption = "Job Three"
-
Case Is = 4
-
Label1.Caption = "Job Four"
-
Case Is = 5
-
Label1.Caption = "Job Five"
-
Case Is = 6
-
Label1.Caption = "Job Five"
-
End Select
-
-
End Sub
-
Requirements:
Command Button "command1"
Label "label1"
Action:
Clicking on command1 will make a random number from 1 to 6 and depending on the result (number) changes label1's caption to a specified (job title).
Customize:
Change the names of command1 and label1 through out the script
Change what the specified (job titles) are
Information:
Case = 1 is like saying "If {variable} = 1 then" it is used when a lot of different outcomes are possible, and it is how you will be taught to use them in the near future in your class ;)
P.S. You can't copyright common code that's used in everyday use of Visual Basic, only something you have created... if you attempted to patent this it would fail under being "not unique". Just so you know...