Results 1 to 7 of 7

Thread: How does the toolbar work?

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    May 2009
    Posts
    876

    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

  2. #2
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    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

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    May 2009
    Posts
    876

    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

  4. #4
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    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.

  5. #5
    Frenzied Member
    Join Date
    Jan 2009
    Location
    Watch Window(Shift+f9)
    Posts
    1,879

    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

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    May 2009
    Posts
    876

    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?

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    May 2009
    Posts
    876

    Re: How does the toolbar work?

    Any ideas ?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width