Link to home
Start Free TrialLog in
Avatar of kkbenj
kkbenj

asked on

VB6 Problems with SetFocus

I checked my version and it is 6.  But I do not have SetFocus as an option on my textbox.  Am I missing a setting?
Avatar of DerZauberer
DerZauberer

Are you using the regular VB6 TextBox control or some other component?
There should be a SetFocus method on the TextBox.

TextBox1.SetFocus

Avatar of HooKooDooKu
A textbox doesn't have a SetFocus "option".  It has a SetFocus "command" that you call.

If you are not seeing "SetFocus" in the auto-complete, try typing it anyway.

Specifically, try creating a new project and place two textboxs and two command buttons on the form.  Then put the following code inside the form and see if it will compile and execute.


Private Sub Command1_Click()
    Text1.SetFocus
End Sub
Private Sub Command2_Click()
    Text2.SetFocus
End Sub
Avatar of kkbenj

ASKER

I have forced the SetFocus even though it does not present.  It gives this error:
Compile error:
Method or data member not found
Is the error about 'SetFocus' method or is it because you misspelled textbox name or because your code cannot see the textbox or is in wrong context?

Maybe give some sample code or more details.
Avatar of kkbenj

ASKER

The code and I always cut and paste field names to ensure I don't misspell.

When I click the New button, is highlights the .SetFocus and displays the compile error above.
Private Sub btnNext_Click()
  txtParmNm.SetFocus
End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Martin Liss
Martin Liss
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kkbenj

ASKER

Yes - that was the problem.  Thanks!
You're welcome.