VB heroes, why the close button to point two.

The code for the Form1 control.:
Private Sub Text1_GotFocus()
Load Form2
Form2.Show
End Sub
The code for the Form2 control.:
Private Sub Command1_Click()
Form1.Text2.SetFocus
Unload Form2
'Unload Form2
End Sub

I want to click on the Form1.Text1 Form2 dialog box pops up, and then close the focus of mobile Form2 dialog and Form1 to
Form.Text2, but why every time need to click two times the Command1 command button to close the dialog box.? ?

Started by Winnie at November 30, 2016 - 5:14 AM

The code for the Form1 control.:
Private Sub Text1_Click()
Load Form2
Form2.Show
End Sub

Posted by Sandra at December 08, 2016 - 5:24 AM

'form1
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Form2.Show
End If
End Sub

'form2
Private Sub Command1_Click()
Form1.Text2.SetFocus
Unload Form2
End Sub

Posted by Sandra at December 22, 2016 - 5:33 AM

My intention was not clear, feel shy, I want to get a pop-up dialog box focus with key tab, but not click, now use Getfocus will appear two times will be closed, this how to deal with ah, but you give me the code I have tried, did not seem to be ah, dear.

Posted by Winnie at January 06, 2017 - 6:14 AM

This is the code yourself.

You just after Form1.Text2.SetFocus added: DoEvents.

Posted by Webster at January 07, 2017 - 6:57 AM

Thank you, ha ha, , The success,.

Posted by Winnie at January 11, 2017 - 7:03 AM

To solve the problem for you, you seek safety in flight.

Posted by Webster at January 14, 2017 - 7:33 AM