Jump to content
Sign in to follow this  
Insight

How To: Make A Calculator in Visual Basics (2010)

Recommended Posts

Hello this is my first of many Visual Basics Tutorial! I hope this helps you!

 

First you need-

 

1. visual basic 2008 or 2010 (http://www.microsoft.com/visualstudio/eng/products/visual-studio-express-products)

2. some time and paticence

3. A Brain 

 

Also Im not going to tell you where to place the Buttons, labels, textboxs, etc..

 

 

You will be using

2 TextBoxs 

2 Buttons

1 Group Box

4 Radio Buttons

3 Labels

1 Label Sign

 

 

First You need to set the Values

 

 

Public Class Form1
    Dim Num1 As Single
    Dim Num2 As Single
    Dim Answer As Single
 

 

 

Buttons

 

Submit  Button Code-

 

 

 

 Private Sub ButtonSubmit_Click(sender As System.Object, e As System.EventArgs) Handles ButtonSubmit.Click
        Num1 = TextBoxNum1.Text
        Num2 = TextBoxNum2.Text
        If RadioButtonAdd.Checked = True Then
            Answer = Num1 + Num2
        ElseIf RadioButtonSub.Checked = True Then
            Answer = Num1 - Num2
        ElseIf RadioButtonMultiply.Checked = True Then
            Answer = Num1 * Num2
        ElseIf RadioButtonDivide.Checked = True Then
            Answer = Num1 / Num2


        End If
        LabelAnswer.Text = Answer


    End Sub
 

 

Close Button Code-

 

 

 

 Private Sub ButtonClose_Click(sender As System.Object, e As System.EventArgs) Handles ButtonClose.Click
        Close()
    End Sub
 

Group Box

 

-Make it say "Pick Operation"

 

Radio Buttons

 

Radio Button 1 (Add)-

 

 

 

Private Sub RadioButtonAdd_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles RadioButtonAdd.CheckedChanged
        LabelSign.Text = "+"
    End Sub
 

 

Radio Button 2 (Subtraction)-

 

 

 

 

    Private Sub RadioButton2_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles RadioButtonSub.CheckedChanged
        LabelSign.Text = "-"
    End Sub
 

 

Radio Button 3 (Multiplication)-

 

 

 

Private Sub RadioButton3_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles RadioButtonMultiply.CheckedChanged
        LabelSign.Text = "*"
    End Sub
 

 

Radio Button 4 (Division)-

 

 

 

Private Sub RadioButtonDivide_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles RadioButtonDivide.CheckedChanged
        LabelSign.Text = "/"
    End Sub
End Class
 

 

Labels

 

Label 1- Label1 (Name it "1st Number")

Label 2- Label2 (Name it "2nd Number")

Label 3- LabelAnswer (Name it "Answer")

 

 

Label Sign

 

 

 

 Private Sub LabelSign_Click(sender As System.Object, e As System.EventArgs)


    End Sub
 

 

 

My End Result

 

 nvnnh2.png

Share this post


Link to post
Share on other sites

Im doing it!!!!!

Share this post


Link to post
Share on other sites

Nice, im gonna try to make it a bit more advanced and easier to use.

Share this post


Link to post
Share on other sites

Im doing it!!!!!

Sweet! If you need help PM Me!

 

Nice, im gonna try to make it a bit more advanced and easier to use.

Cool! Made this really for beginners, Good for you to step it up a notch! Post some screenshots of the finished product 

Share this post


Link to post
Share on other sites

Sweet! If you need help PM Me!

 

Cool! Made this really for beginners, Good for you to step it up a notch! Post some screenshots of the finished product 

Alright im gonna try to add number buttons :P

Share this post


Link to post
Share on other sites

Im downloading the software right now

Share this post


Link to post
Share on other sites

Alright im gonna try to add number buttons :P

Its easy, if you need help HMU thru PMs

 

Im downloading the software right now

Sweet hope you learn some coding! i'll make another one Monday or Wednesday! For a Spammer or something

Share this post


Link to post
Share on other sites

Nice program! Will test out when I get on PC. Meanwhile send me an invite to the programmers group.

Share this post


Link to post
Share on other sites

I am going to try this later on. :)

Share this post


Link to post
Share on other sites

Nice program! Will test out when I get on PC. Meanwhile send me an invite to the programmers group.

Sweet hope it goes good. Sadly im not in the Programmers Group so I cannot invite you!

 

 

 

I am going to try this later on. :)

If you need help PM me

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×