Reviewr ng 3rd at 4th Year
Page 1 of 1
Reviewr ng 3rd at 4th Year
Programming Codes and Function
Sample Code:
Private Sub Command1_Click( )
Image1.Visible = False
Label1.Caption = Int(Rnd * 10)
If (label1.caption = 7) or (Label2.captio = 7) Then
Image1.Visible = True
Else
MsgBox “You Lose! Spin Again…” , 0, “Message Alert”
End If
End Sub
With the 1st Line of the Program: Private Sub Command1_Click( )Private Sub = is used to assign codes in a specific object which is the Command Button (Command1).
Command1 = the name of the object that the event will occur.
Click( ) = tells the event that will occur in an object. * the program will run by clicking the command button.
With the 2nd Line of the Program: Image1.Visible = False
Visible = False *here, the image object will not be displayed on the screen because the visibility of the image object is set to false.
With the 3rd Line of the Program: Label1.Caption = Int(Rnd * 10)
Caption = is an object property that displays a character or group of words.
Int = is a reserved word that assigns a text or caption of an object into integer form.
Rnd = is a reserved word that arrange series of numbers in random order.
With the 4th Line of the Program: If (label1.caption = 7) or (Label2.captio = 7) Then
If … Then = is a statement used in decision making where in if the caption of label1 is 7 or the caption of label2 is 7 then a series of command will be executed.
With the 5th Line of the Program:Image1.Visible = True
Visible = True **here, the image object will be displayed on the screen because the visibility of the image object is set totrue.
With the 6th Line of the Program:Else
Else = is used as an option in an If … Then Statement.
With the 7th Line of the Program:
MsgBox “You Lose! Spin Again…” , 0, “Message Alert”
MsgBox = is a reserved word used to display a message box on the screen.
Sample Code:
Private Sub Command1_Click( )
Image1.Visible = False
Label1.Caption = Int(Rnd * 10)
If (label1.caption = 7) or (Label2.captio = 7) Then
Image1.Visible = True
Else
MsgBox “You Lose! Spin Again…” , 0, “Message Alert”
End If
End Sub
With the 1st Line of the Program: Private Sub Command1_Click( )Private Sub = is used to assign codes in a specific object which is the Command Button (Command1).
Command1 = the name of the object that the event will occur.
Click( ) = tells the event that will occur in an object. * the program will run by clicking the command button.
With the 2nd Line of the Program: Image1.Visible = False
Visible = False *here, the image object will not be displayed on the screen because the visibility of the image object is set to false.
With the 3rd Line of the Program: Label1.Caption = Int(Rnd * 10)
Caption = is an object property that displays a character or group of words.
Int = is a reserved word that assigns a text or caption of an object into integer form.
Rnd = is a reserved word that arrange series of numbers in random order.
With the 4th Line of the Program: If (label1.caption = 7) or (Label2.captio = 7) Then
If … Then = is a statement used in decision making where in if the caption of label1 is 7 or the caption of label2 is 7 then a series of command will be executed.
With the 5th Line of the Program:Image1.Visible = True
Visible = True **here, the image object will be displayed on the screen because the visibility of the image object is set totrue.
With the 6th Line of the Program:Else
Else = is used as an option in an If … Then Statement.
With the 7th Line of the Program:
MsgBox “You Lose! Spin Again…” , 0, “Message Alert”
MsgBox = is a reserved word used to display a message box on the screen.
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|