|
-
Aug 23rd, 2012, 03:29 AM
#1
Thread Starter
Fanatic Member
How does the toolbar work?
Hi guys, I've created a toolbar with 4 buttons...
How do i add code to a button?
Example i want the first button i added to show a msgbox when clicked the second to start a timer e.t.c
How do i add a code to each button individually?
regards,
Jamie
-
Aug 23rd, 2012, 04:48 AM
#2
Re: How does the toolbar work?
Well, pretty much just as described in the VB6 docs.
Simple example with 3 buttons, Key values set to One, Two, Three:
Code:
Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
With Button
'Using .Key, or use .Index though it can be more work to manage
'as you maintain your program over time.
Select Case .Key
Case "One"
MsgBox "One"
Case "Two"
MsgBox "Two"
Case "Three"
MsgBox "Three"
End Select
End With
End Sub
-
Aug 23rd, 2012, 06:34 AM
#3
Thread Starter
Fanatic Member
Re: How does the toolbar work?
Fantastic, one last question. When case three is pressed how can i mkae the caption of that button change from "Mute" to "Unmute" ?
Thanks
Jamie
-
Aug 23rd, 2012, 11:50 AM
#4
Re: How does the toolbar work?
That shouldn't be a problem. The Button objects have a Caption property that appears to be read/write at runtime.
-
Aug 23rd, 2012, 06:22 PM
#5
Frenzied Member
Re: How does the toolbar work?
try the following
Code:
Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
With Button
'Using .Key, or use .Index though it can be more work to manage
'as you maintain your program over time.
Select Case .Key
Case "One"
MsgBox "One"
Case "Two"
MsgBox "Two"
Case "Three"
MsgBox "Three"
.caption="Unmute"
End Select
End With
End Sub
-
Aug 24th, 2012, 03:39 AM
#6
Thread Starter
Fanatic Member
Re: How does the toolbar work?
Brilliant stuff pal, Really appreciate that!
I've tried doing an if statement but does not seem to work?
I did
if .caption = "mute mic" then
.caption = "Unmute mic"
Else :
.caption ="mute mic"
End if
I basically want it so when it's clicked the caption changes from mute mic to unmute mic. Then when clicked again and unpressed it changes from Unmute mic back to mute mic.
Any ideas?
-
Aug 27th, 2012, 09:39 AM
#7
Thread Starter
Fanatic Member
Re: How does the toolbar work?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|