[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


Deleguate setfocus method

Posted on 2007-07-20
Medium Priority
Last Modified: 2013-12-26

I've a usercontrol on VB6 and I would like to know how to deleguate the setfocus method?

Thanks by advance.
Question by:esohier
  • 2
  • 2
LVL 10

Expert Comment

ID: 19530577
What do you mean by "deleguate" (delegate?)

Author Comment

ID: 19530755

I would like to give the method to the form to make this sample:

Sub Form _load


End Sub
LVL 10

Accepted Solution

Clif earned 150 total points
ID: 19530911
Oh, I see.  You want a control to have focus when the form is first displayed (but can't do it in the Form_Load() event, since the controls aren't visible during the load event).

You have two options

1. In design mode, set the TabIndex for the control to 0.  This will cause the control in question to acquire focus automatically when the form is loaded (no code required).

2. Although the Form_Load() event is not a valid place to set the focus of a control, you can put the code in the form's paint event (or even the Activate event).  You shoud set up a static variable so it only hits once (and not every time the form is repainted):

Private Sub Form_Paint()
    Static bSkip As Boolean
    If Not bSkip Then
    End If
End Sub

Author Comment

ID: 19530951
Very thanks. That Ok.

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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…
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…
Suggested Courses
Course of the Month19 days, 14 hours left to enroll

872 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