?
Solved

void 0 on a button

Posted on 2003-11-22
3
Medium Priority
?
296 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 200 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

777 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