Most of the time, you need to focus on the text box, but in many cases, calling in the form load event is inevitable, which we can avoid, but if we avoid comparison in some cases, for example, calling the listindex attribute of combox triggers the click event. In most cases, we need to do some focus setting in this event.
All the click events of the combox affected by the load event cause the setfocus of the textbox to be sometimes incorrect, but sometimes it is normal. How can this problem be solved.
The solution is as follows:
Wrap the otext. setfouce method as the following code
'Set the focus of the text box
Public sub textboxsetfocus (otext as textbox)
If otext. Visible then otext. setfocus
End sub
You can use this function later.
The principle is very simple. It should be because textbox is invisible when setfocus is triggered in the load event, so when setfocus is called, process the textbox visibility.