03-07-2012, 06:51 PM
Visual Basic Guide - Buttons
This will be a simple guide on buttons and what to do with them.
To start, you will need to download Visual Basic 2010.
Do so by going here.
Then, create a new project and press ok.
1 - Adding a Button
2 - Assigning the button a task
3 - Form2 + Other Codes
4 - Saving your program
Thank you for reading my tutorial.
I will be making more Visual Basic tutorials in the future.
This will be a simple guide on buttons and what to do with them.
To start, you will need to download Visual Basic 2010.
Do so by going here.
Then, create a new project and press ok.
1 - Adding a Button
Spoiler (Click to View)
A.Find the toolbox.
If you can't see it, press ctrl + alt + x to open it.
If you can't see it, press ctrl + alt + x to open it.
2 - Assigning the button a task
Spoiler (Click to View)
Now that you have an Open and Close button, you'll want to
actually make it do these things. Double Click on the close button.
A new window will pop up, this is were code goes.
Type in Me.Close - If you are closing Form1 with a button, don't use Form1.Close, you can only close other forms using Form#.Close, use Me.Close Instead.
It should look like this
=====================
Now the Open button.
First, right click on WindowsFormApplication1>add>windows_form
Like so
This form will be referred to as "Form2".
Double click on Open in form1 and type "Form2.Show", you can also
type Me.Hide so when you click on the open button and open form2, form1 becomes hidden.
So, like this
actually make it do these things. Double Click on the close button.
A new window will pop up, this is were code goes.
Type in Me.Close - If you are closing Form1 with a button, don't use Form1.Close, you can only close other forms using Form#.Close, use Me.Close Instead.
It should look like this
Code:
Me.Close()
=====================
Now the Open button.
First, right click on WindowsFormApplication1>add>windows_form
Like so
This form will be referred to as "Form2".
Double click on Open in form1 and type "Form2.Show", you can also
type Me.Hide so when you click on the open button and open form2, form1 becomes hidden.
So, like this
Code:
Form2.Show()
Me.Hide()
3 - Form2 + Other Codes
Spoiler (Click to View)
Now that Form2 is open, you can debug your program.
Press the green play button and test out your program!
In Form2.
You can drag in a "Label" and "Button" and do this.
Click on the label you have dragged in and change the text to "You have just opened my test program"
and in the button, put the following
Some other commands that may, or may not have been included are:
Press the green play button and test out your program!
In Form2.
You can drag in a "Label" and "Button" and do this.
Click on the label you have dragged in and change the text to "You have just opened my test program"
and in the button, put the following
Code:
Me.Close()
Form1.Close()
Some other commands that may, or may not have been included are:
Code:
Me.Hide
Me.Show
Me.Close
Form#.Close
Form#.Show
Form#.Hide
4 - Saving your program
Spoiler (Click to View)
Go to File>Save all and save your program.
Then, right click the same thing you right clicked to add form2 and click build.
To the right from the green play button, you'll see a dropdown menu that has "Debug" in it, change it to release and build it again.
Now go to
C:\Users\<Accountname>\Documents\Visual Studio 2010\Projects\WindowsApplication1\WindowsApplication1\bin\Release
You will see an application or .exe.
Open it and you have your program!
Here is the download to my finished result
Then, right click the same thing you right clicked to add form2 and click build.
To the right from the green play button, you'll see a dropdown menu that has "Debug" in it, change it to release and build it again.
Now go to
C:\Users\<Accountname>\Documents\Visual Studio 2010\Projects\WindowsApplication1\WindowsApplication1\bin\Release
You will see an application or .exe.
Open it and you have your program!
Here is the download to my finished result
Thank you for reading my tutorial.
I will be making more Visual Basic tutorials in the future.