December 9th, 1999, 04:04 AM
I have created a tool bar with serveral buttons on it.
I need to operate a button, from a routine how is the call made ?
Thanks James
I need to operate a button, from a routine how is the call made ?
Thanks James
|
Click to See Complete Forum and Search --> : ToolBar Buttons December 9th, 1999, 04:04 AM I have created a tool bar with serveral buttons on it. I need to operate a button, from a routine how is the call made ? Thanks James valkyrie December 9th, 1999, 04:35 AM Hi, You can start by double-clicking your toolbar. This will bring up the default "Click" command, which is private Sub Toolbar1_ButtonClick(byval Button as MSComctlLib.Button) Next, you can check which button has been clicked by putting in a "Select Case" statement. For example, I have 2 buttons on my toolbar, so this is my select statement Select Case Button.Index > 0 Case Button.Index = 1 'Buttons start from index of 1 'Do something Msgbox "First button" else 'Do something else Msgbox "2nd button" End select And that is how you code your toolbar! Hope that this helps... Cheers, ____________________________________ The VB Bugs in my Life... December 9th, 1999, 05:01 AM Sorry this is not what I ment I have that bit working fine. What I need to do is call button from a different routine, not from actually pressing the button. I have a button group containing two buttons one starts my program and one stops it. If an error occurs I need to stop the program therefore calling that stop button. So some how I need to call that routine with the right index specified. I tryed Toolbar1_ButtonClick(2) 'Call rotine with index = 2 but got a type mismatch Please help if you can. Thanks James valkyrie December 9th, 1999, 07:06 PM Sorry mate... I'm not so sure about this one... but I do know that it is best to put your "Cancel" routine in a separate sub of your own. This is useful when somewhere else in your program needs this "Cancel" routine in the future. Otherwise, you can put an additional Button on a form and put some code into it. Make the button "invisible" (Command1.Visible = False). So, if you do need to get out, just call this button's "Command1_Click" routine... it works fine for me... Hope that this suggestion helps... ____________________________________ The VB Bugs in my Life... valkyrie December 9th, 1999, 07:59 PM Hello again!! Got a solution from another mate. Anyway, your problem comes from not using the "Call" statement. According to my friend, sometimes, calling a subroutine without the call statement causes an error. Anyway, here is a portion of the code... call Toolbar1_ButtonClick(Toolbar1.Buttons.Item(2)) Hope that this helps... (Thanks to chyow for this...) =) Cheers, ____________________________________ The VB Bugs in my Life... Ravi Kiran December 10th, 1999, 03:43 AM This one of those quircks of Vb syntax. You can call an event procedure like you are trying. Dont include the braces: ie 'either just Toolbar_Click 2 'or Call Toolbar_Click(2) RK codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |