Results 1 to 7 of 7

Thread: Tool Bar question..

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2002
    Posts
    109

    Tool Bar question..

    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..

  2. #2
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758
    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:
    1. Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
    2.     Select Case Button.Key
    3.         Case "Insert"
    4.             'Call procedure to Insert a record
    5.         Case "Update"
    6.             'Call procedure to Update a record
    7.         Case "Delete"
    8.             'Call procedure to Delete a record
    9.     End Select
    10. End Sub

  3. #3
    Frenzied Member Microbasic's Avatar
    Join Date
    Mar 2001
    Posts
    1,402
    Use the ButtonClicked Event:

    VB Code:
    1. Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
    2.     Select Case Button.Key
    3.         Case "New"
    4.             '...
    5.     End Select
    6. End Sub


    MicroBasic
    Dragon Shadow Trainer

    There is no good or evil in the world...only programmers and fools .

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Dec 2002
    Posts
    109

    hmm so for example..

    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

  5. #5
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758
    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:
    1. If MsgBox("Do you have this program installed?", vbYesNo) = vbYes Then
    2.    Shell ("C:\Program Files\Vantive32\vantiv32.exe")
    3. End if

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Dec 2002
    Posts
    109

    hmmm

    '
    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?

  7. #7
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758
    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.

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