Generally, we add controls to the form at the time of designing the form (at design time), but Visual Basic also provides a facility to increase the number of control array at run-time using the Load statement.
Example:
Create a form and add a Command Button. Change Indexnya properties with the number 0.
In the Command Button to add the program code, such as listing 2.
Listing 2. Click on Command1 Event
Private Sub Command1_Click (Index As Integer)
Load Command1 (1)
Command1 (1). Left = Command1 (0). Left
Command1 (1). Top = Command1 (0). Top + Command1 (0). Height
Command1 (1). Caption = "New Command"
Command1 (1). Visible = True
End Sub
Note that the procedure Command1_Click there Index As Integer parameter that should be added.
Run the application. If the Command Button is clicked, it automatically added a new Command Button right below it.
Nah, that tips and tricks on help you make your application with Visual Basic.
Tidak ada komentar:
Posting Komentar