Hey guys I am having difficulty with the toolbar.. I get my button in.. but were to a do my code for each individual button?
right now they all do the same.?? I am confused were to I specify what each one does thanks..
Printable View
Hey guys I am having difficulty with the toolbar.. I get my button in.. but were to a do my code for each individual button?
right now they all do the same.?? I am confused were to I specify what each one does thanks..
Use the Toolbar's ButtonClick or the ButtonMenuClick (dropdown types ) events. These events get passed a reference to a Button or ButtonMenu object. Then do a Select Case on the Index or Key properties.
VB Code:
Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button) Select Case Button.Key Case "Insert" 'Call procedure to Insert a record Case "Update" 'Call procedure to Update a record Case "Delete" 'Call procedure to Delete a record End Select End Sub
Use the ButtonClicked Event:
VB Code:
Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button) Select Case Button.Key Case "New" '... End Select End Sub
So this is an example of my code.. soo it would be something like this.
Dim l As Long
l = MsgBox("Do you have this program installed?", vbYesNo)
If (l = 6) Then
Shell ("C:\Program Files\Vantive32\vantiv32.exe")
Else
End If
Select Case Button.Key
Case "Insert"
Dim l As Long
l = MsgBox("Do you have this program installed?", vbYesNo)
If (l = 6) Then
Shell ("C:\Program Files\Vantive32\vantiv32.exe")
Else
End If
Case "Update"
'Call procedure to Update a record
Case "Delete"
'Call procedure to Delete a record
Well, if that's the code you want to run when the user clicks your button whose key is "Insert" then yes.
OT : Use constants whenever you can. It makes your code more readable. for example
VB Code:
If MsgBox("Do you have this program installed?", vbYesNo) = vbYes Then Shell ("C:\Program Files\Vantive32\vantiv32.exe") End if
'
Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
Select Case Button.Key <=- what ??
Case Vantive
MsgBox ("test")
Case Helpdesk
MsgBox ("test2")
End Select
'
mm something like this?!
button key represents what?
Button.Key is a string and is whatever you want it to be. On the Toolbar property page there is a button tab. Select the button and set the key.