Solved

void 0 on a button

Posted on 2003-11-22
3
293 Views
Last Modified: 2010-05-01
Hi I'm just wondering if its possible to have buttons that executes code on click event without setting the button as focus.
Like in javascript we use "void 0;"

Example(I don't use a textbox in my project but dhtm editing component) :
We have an textbox and a button. Focus is on the textbox and then I press the button an click event adds "test" to the textbox. The textpointer is still blinking in the textbox.
0
Comment
Question by:thor918
  • 2
3 Comments
 
LVL 9

Expert Comment

by:dancebert
ID: 9802866
No, but you can fake it.  In this code the button gets focus when you click it, but the click events shifts the focus to the text box.  The user nevers knows the button had focus but the program does, so the code in Command1_GotFocus executes.

Private Sub Command1_Click()
    Debug.Print "Button click"
    Text1.Text = "test"
    Text1.SetFocus
End Sub

Private Sub Command1_GotFocus()
    Debug.Print "Button got focus"
End Sub

Private Sub Form_GotFocus()
    Debug.Print "text1 got focus"
End Sub
0
 
LVL 9

Accepted Solution

by:
dancebert earned 50 total points
ID: 9802879
Oops, there was a typo.  The correct code is:

Private Sub Command1_Click()
    Debug.Print "Button click"
    Text1.Text = "test"
    Text1.SetFocus
End Sub

Private Sub Command1_GotFocus()
    Debug.Print "Button got focus"
End Sub

Private Sub Text1_GotFocus()        ''' this line changed
    Debug.Print "text1 got focus"
End Sub


0
 
LVL 2

Author Comment

by:thor918
ID: 9812484
The toolbar component will give me what I was looking for

Thanks for the help
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
using web browser with BING 40 135
VB6 ListBox Question 4 55
Excel Automation VBA 19 102
Create Files based on Cell Values in a Range in Excel 12 43
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question