KNOWN VISUAL BASIC (Part 5)
1.1. Event With Program Code
Visual programming is event-driver, which means that the program works based on events that occur when a given object instance action button is pressed, the selected option, or after typing something in the text and in the press [Enter]. To make this event live click on the components of the user interface display that was made.
Example 3:
In the example 2, click on the form (the blanks are not used any other components), then the display will appear as shown below 5:
Figure 2.5. Display for program code
Consider drawing 2.5, while in-form will appear click the Load event, is due to the default event for the form is loaded. And automatically in the source code for functions already provided in the form load event is written:
Private Sub Form_Load ()
End Sub
In this function written in program code. This program code is run when the form is called. This event can be replaced in the [Event], note that the event in every component, including numerous forms, live selected according to application needs.
Example 4:
In the example 2, click on the command1, hence the event on the program code as follows:
Private Sub Command1_Click ()
End Sub
Add the program to the source code is that it becomes:
Private Sub Command1_Click ()
Label2.Caption = Text1.Text
End Sub
This program means that what is typed in text1 will be displayed at Label2. Then click on command2, and add code so that the program becomes:
Private Sub Command2_Click ()
End
End Sub
End command, meaning the program out and completed. Save the form and this project by way of select menu [File]>> [Save Project], give the name of the form and name of the project formLatihan21 with projectLatihan21. Run by pressing the Run icon () on the toolbar. Enter a name such as "Achmad Basuki" in text1, and press the Ok button. The result is as Figure 2.6 berikut.2.5. Display for program code
Private Sub Form_Load ()
End Sub
In this function written in program code. This program code is run when the form is called. This event can be replaced in the [Event], note that the event in every component, including numerous forms, live selected according to application needs.
Example 4:
In the example 2, click on the command1, hence the event on the program code as follows:
Private Sub Command1_Click ()
End Sub
Add the program to the source code is that it becomes:
Private Sub Command1_Click ()
Label2.Caption = Text1.Text
End Sub
This program means that what is typed in text1 will be displayed at Label2. Then click on command2, and add code so that the program becomes:
Private Sub Command2_Click ()
End
End Sub
End command, meaning the program out and completed. Save the form and this project by way of select menu [File]>> [Save Project], give the name of the form and name of the project formLatihan21 with projectLatihan21. Run by pressing the Run icon () on the toolbar. Enter a name such as "Achmad Basuki" in text1, and press the Ok button. The result is as Figure 2.6 berikut.2.5. Display for program code