Current location - Recipe Complete Network - Complete cookbook - VB menu bar, I want to click a button on the menu bar, and then go to another form to find the code.
VB menu bar, I want to click a button on the menu bar, and then go to another form to find the code.
Suppose there is a button command 1 on the form 1. After pressing the button, form 1 disappears and form2 is displayed. The code is as follows:

Private subcommand 1_Click ()

Unload form 1' Unload form 1.

Load form2' loads form2 (note that it is only loaded here, but it has not been displayed yet, and it needs the next statement to be displayed).

Form2.show' displays Form2.

End joint

If you just want to click the button, the original form 1 is still there, and form2 is displayed to get the focus. The code is as follows:

Private subcommand 1_Click ()

Load form2' loads form2 (note that it is only loaded here, but it has not been displayed yet, and it needs the next statement to be displayed).

Form2.show' displays Form2.

Table 2. "setfocus”form 2 gets the focus and will be displayed in front of the screen.

End joint