03-19-2014, 08:46 PM
Today I am going to show all you newbies to the coding world how to make a Calculator in Visual Basics, to do this tutorial I will be using Visual Studio 2013.
Alright lets get started on this. I have done what I can to make this easy to follow.
Step One
You will want to create a new project and title it what ever you want, for this I have called it "Calculator".
You will also want to make sure on Visual Studio that both Common Controls (appears on left) and Properties (appears on right) show up on the screen.
Once you start a new project this will appear in your Form (middle)
![[Image: UoROm0r.png]](http://i.imgur.com/UoROm0r.png)
Step Two
We will now add button's, textbox's and a label to the program so people know what the program is for.
Here is an example of what it should look like.
![[Image: P5khZ6H.png]](http://i.imgur.com/P5khZ6H.png)
Remember to title all of your labels, textboxes and buttons.
To name them you simply Click the thing you want to name > Go to properties > Design > (Name)
to change the display text from "label" to anything simply Click the thing you want to name > Go to properties > Apperance > Text
lbl - Label
btn - Button
txt - TextBox
Here is what I called all of mine,
Now go back to the part that should be named "Private Sub btnAdd_Click(sender As Object, e As EventArgs) Handles btnAdd.Click" and add the following code.
Always make sure you code is between "Private Sub" after all that text click enter and when done the code make sure "End Sub" is after your code.
Add
Once that is done you just change the + Simble on each button (subtract etc) but make sure you go back to the design (program display) and double click on each button to add it.
Subtract
Multiply
Divide
Squareroot is not as easy as the others, you can look on the web for the code but here it is anyways.
Squareroot
Here is the code for the clear button, really simpe and easy to follow, double click the button and add the following.
Step Four
If you are lazy and simply want to add the buttons and name them exactly as I did then here is the full code!
Step Five
Time to test the program to make sure there is no errors, here is a video I made of me testing it.
This program is nowhere near complete nor tested for bugs etc.
It is made to show people how easy it can be to make these programs.[/hide]
Alright lets get started on this. I have done what I can to make this easy to follow.
Step One
You will want to create a new project and title it what ever you want, for this I have called it "Calculator".
You will also want to make sure on Visual Studio that both Common Controls (appears on left) and Properties (appears on right) show up on the screen.
Once you start a new project this will appear in your Form (middle)
![[Image: UoROm0r.png]](http://i.imgur.com/UoROm0r.png)
Step Two
We will now add button's, textbox's and a label to the program so people know what the program is for.
Here is an example of what it should look like.
![[Image: P5khZ6H.png]](http://i.imgur.com/P5khZ6H.png)
Remember to title all of your labels, textboxes and buttons.
To name them you simply Click the thing you want to name > Go to properties > Design > (Name)
to change the display text from "label" to anything simply Click the thing you want to name > Go to properties > Apperance > Text
lbl - Label
btn - Button
txt - TextBox
Here is what I called all of mine,
Hidden Content
Now go back to the part that should be named "Private Sub btnAdd_Click(sender As Object, e As EventArgs) Handles btnAdd.Click" and add the following code.
Always make sure you code is between "Private Sub" after all that text click enter and when done the code make sure "End Sub" is after your code.
Add
Hidden Content
Once that is done you just change the + Simble on each button (subtract etc) but make sure you go back to the design (program display) and double click on each button to add it.
Subtract
Hidden Content
Multiply
Hidden Content
Divide
Hidden Content
Squareroot is not as easy as the others, you can look on the web for the code but here it is anyways.
Squareroot
Hidden Content
Here is the code for the clear button, really simpe and easy to follow, double click the button and add the following.
Hidden Content
Step Four
If you are lazy and simply want to add the buttons and name them exactly as I did then here is the full code!
Hidden Content
Step Five
Time to test the program to make sure there is no errors, here is a video I made of me testing it.
This program is nowhere near complete nor tested for bugs etc.
It is made to show people how easy it can be to make these programs.[/hide]