Sabtu, 25 Juli 2009

Adding a Control Array When Run-Time

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.

Tips n Tricks

Simple Tricks protect CD Collection | Tips Making Weakness Program | Password characters (*)
| Center Screen | Adding a Control Array When Run-Time

Contact Us

To contact us, you can ask via e-mail at khairul.annas @ gmail.com, or on annas_khairul@yahoo.co.id. Or you can also ask questions via YM! in: annas_khairul@yahoo.co.id

Thanks
Khairul Anas