Solved

void 0 on a button

Posted on 2003-11-22
3
292 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Problem to skip loop 6 64
Visual Studio 2005 text editor 10 44
Can we place a tooltip on the actual vb6 form 5 48
Collapse and expand table in Word 2010 2 32
Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

860 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