How to Open a New Form with the Press of a Button
Having a program with everything on one form would be extremely cluttered, that is why most programs are split into many different forms and windows. This is a very basic tutorial on how to open a new form/window by simply clicking on a button. As always, I¡¯d reccommend trying to mess around with the various settings you have available to you. Tutorials should be used as learning tools, not just a quick fix.
- Launch Visual Basic 2005 Express
- Go to File ¨¤ New Project
- Press OK
- In the Toolbox (it should be on the left of the screen) double click on the Button control
- A button will appear in your form, you can resize it, and move it as you please.
- Go to Project ¨¤ Add Windows Form
- Then click on Add
- Go back to the original form (Form1.vb)
- Double click on the Button ¨C a code Window will appear.
- Type in, just before the End Sub: Form2.Show()
Basically, all you are doing is typing the name of the form, and putting .Show() after it. - Now you can Start Debugging to test the program ¨C no errors should occur, as it is a very simple program.
discuss this topic to forum
