Visual Basic Tutorial #1 | Calculator
How to make your own calculator
What you are making:
Difficulty: Very easy
Time: 5-10 minutes
Time: 5-10 minutes
Step 1:
Create a New Project -> Windows Forms Application
Step 2:
Create:
4 Buttons
2 Labels
2 Text Box
Step 3:
Rename the buttons to +, -, x, /
![[IMG]](http://gyazo.com/e9b7744f5426005a1edae27e924090da.png)
Move the two text box's to the top
![[IMG]](http://gyazo.com/1ca554f36ce23979835ba8fb7206b0f8.png)
Click the labels and remove the text saying Label.
You should have something looking like this.
![[IMG]](http://gyazo.com/43aa6ef865af77f4a4fa409771725acd.png)
Do that to both, put one in-between the two Text box's and the other where you would like the answer to show.
Should look something like this.
![[IMG]](http://gyazo.com/f6566b435b10ce198e2f5da1fc498ed1.png)
Step 4: Coding:
Double click the + button
It should open up this.
![[IMG]](http://gyazo.com/764a53984cd8e051a1e2905559a02af1.png)
Add this code:
Code (Text):
Label2.Text = "+"
Label1.Text = Val(TextBox1.Text) + Val(TextBox2.Text)
Codes for other buttons
Step 5:
Check the error list:
![[IMG]](http://gyazo.com/f53d8343dcb3d1103011599482b7168e.png)
If there are 0 then you can go ahead and test it out.
Click the debug button. ![[IMG]](http://gyazo.com/15ce7c468d2004472c85435bf3437ffa.png)
![[IMG]](http://gyazo.com/15ce7c468d2004472c85435bf3437ffa.png)
Now try it out and you may need to move the labels so it looks good.
Then you are done!
![[IMG]](http://gyazo.com/792306d20849b89e46d66af81a5adba9.png)








0 comments