The VB 6 allows you to add a toolbar to the form object. In this article we will explain the method to add the toolbar .
To create a toolbar you have to follow steps given below.
- Add component, “Microsoft Windows Common Control 6.0″
- Select Toolbar control from the Toolbox in VB 6 IDE.
- Configure Toolbar buttons with Caption and Key properties.
- Write code for Toolbar and its buttons.
Now, we will follow the steps above and create a toolbar for the VB 6 form object.
Step 1: Add Microsoft Windows Common Control 6.0
For this step, go to Project tab in your VB 6 IDE, select Components. It will open up the components window.
You should see the following window.
In the components window, select “Microsoft Windows Common Control 6.0” and you will add Toolbar control to the toolbox.
Step 2 – Select Toolbar Control from toolbox
Select the Toolbar from toolbox in VB 6 IDE. See the following figure below.
Step 3: Configure the Toolbar control buttons
You need to go to toolbar properties to add buttons to the toolbar. Right click on the toolbar and click Properties.
Once the toolbar property is open, select the Buttons tab and click Insert to add new button. Here you can change the index value, you can give new caption to the buttons, given a key value.
The key value is important to access the toolbar button and give it some action once the button is clicked. We will see the next step.
Step 4: Add code for the buttons
You have to add some code for the toolbar, so that, when you click the button, some action take place.
Add following code:
Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
Select Case Button.Key
Case "File":
MsgBox "This is File"
Case "Edit":
MsgBox "This is Edit"
End Select
End Sub