Posts: 16
Threads: 5
Joined: Mar 2012
Reputation:
0
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
A.Find the toolbox.
If you can't see it, press ctrl + alt + x to open it.
2 - Assigning the button a task
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
Code: Form2.Show()
Me.Hide()
3 - Form2 + Other Codes
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
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
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
Thank you for reading my tutorial.
I will be making more Visual Basic tutorials in the future.
Posts: 5,793
Threads: 268
Joined: Sep 2010
Reputation:
85
03-08-2012, 01:28 AM
(This post was last modified: 03-08-2012, 01:29 AM by AceInfinity.)
I look forward to seeing vb tutorials here, haven't seen contributions in this section for a long time.
you can also assign a handler to it:
Code: AddHandler Button1.Click, AddressOf Testing
Code: Private Sub Testing()
MsgBox("Test")
End Sub
Posts: 16
Threads: 5
Joined: Mar 2012
Reputation:
0
(03-08-2012, 01:28 AM)AceInfinity Wrote: I look forward to seeing vb tutorials here, haven't seen contributions in this section for a long time.
you can also assign a handler to it:
Code: AddHandler Button1.Click, AddressOf Testing
Code: Private Sub Testing()
MsgBox("Test")
End Sub
Maybe to change that around, you can make a tut? :O
Posts: 5,793
Threads: 268
Joined: Sep 2010
Reputation:
85
03-08-2012, 01:36 AM
(This post was last modified: 03-08-2012, 01:36 AM by AceInfinity.)
I am starting up a VB school on my own forum so i'm full for time on making tutorials dedicated for SF But I am making as much I can for the basics. It is very boring though when you have to put yourself in the shoes of a beginner however, so It's been a little slow making them, but lots of content so far before those school forums open up.
I wouldn't be sure of what people would want to know about though even if I was to make just a simple tutorial here.
Posts: 2,216
Threads: 187
Joined: Jul 2011
The tutorial's quite good, but your ToolBox is where others' wont be. So that could be confusing for the beginners, they will be looking for the TB where yours is. You should also try going into a bit more detail with what you can do with the button, like MsgBox, MessageBox, start process, kill process etc... Also try to incorporate some action with a textbox.
E.G: write something in the TextBox and whey they click the Button1 it would show them what was in the text. Basic stuff but it looks good to a beginner.
Posts: 16
Threads: 5
Joined: Mar 2012
Reputation:
0
This is intended for only level 1 learners, only the extreme basics.
Posts: 2,216
Threads: 187
Joined: Jul 2011
(03-09-2012, 03:30 AM)Photoshop Wrote: This is intended for only level 1 learners, only the extreme basics.
Message Boxes are the absolute basics, you can't get any easier that that lol.
Posts: 16
Threads: 5
Joined: Mar 2012
Reputation:
0
(03-09-2012, 10:59 AM)BreShiE Wrote: Message Boxes are the absolute basics, you can't get any easier that that lol. Still, this guide was mostly about getting the buttons to open but a different form.
My next tutorial will be BASIC if statements.
Posts: 5,793
Threads: 268
Joined: Sep 2010
Reputation:
85
I personally don't think super basic tutorials like this will help anyone as there's ample of content already available on the web which goes into a lot more detail than you would have done here. There's lots of online information available in much detail, and I think it would be more beneficial if you make something unique.
Posts: 2,216
Threads: 187
Joined: Jul 2011
(03-09-2012, 06:26 PM)AceInfinity Wrote: I personally don't think super basic tutorials like this will help anyone as there's ample of content already available on the web which goes into a lot more detail than you would have done here. There's lots of online information available in much detail, and I think it would be more beneficial if you make something unique.
This.
But at-least you're trying to contribute, unlike other members I've seen around here lately.
|