ItsMods

Full Version: Making A Simple Calculator!
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Visual Basic Simple Calculator Tutorial

1.Open your Visual basic 2008/2010 and make new project called Calculator

2.Rename window to My First Calculator

3.Make 4 buttons with 20 size of text : 1 button : +, 2 button : - , 3 button : X , 4 Button : %

Picture :
[Image: 24czcdd.jpg]

4.Make 2 Text Boxes

Picture :
[Image: zxpnps.jpg]

5.Now make 2 labels : 1 label let it be down in the middle with no text and second label in the middle of the 2 textboxes with no text too

Codingl

6.Double click on + button and type this :



Code:
Label2.Text = "+"
Label1.Text = Val(TextBox1.Text) + Val(TextBox2.Text)

7.Double Click on The - button and type this :

Code:
Label2.Text = "-"
Label1.Text = Val(TextBox1.Text) - Val(TextBox2.Text)

8.Double click on The X button and type this :

Code:
Label2.Text = "X"
Label1.Text = Val(TextBox1.Text) * Val(TextBox2.Text)

9.Double Click on the % button and type this :

Code:
Label2.Text = "%"
Label1.Text = Val(TextBox1.Text) / Val(TextBox2.Text)

10.Test it and congratz you maded your first calculator!

Picture :

[Image: sy4bgo.jpg]

Video :

how do you change the size of the text in the buttons...? lmao
(08-15-2011, 01:54)TheCodKingz10 Wrote: [ -> ]how do you change the size of the text in the buttons...? lmao

Are you serious..., when you put the button in you can adjust it lol..

change the font size?
(08-15-2011, 12:18)d0h! Wrote: [ -> ]change the font size?

Code:
' {: Gam3rr0rZ :} '

        ' Declaration '
        Dim strFontName As String = MyBase.Font.Name ' Setup font. MyBase.Font.Name will set form's font. You can set custom font using quotes mark "", inside of "" input the valid font name(needs to be installed).
        Dim iFontSize As Integer = 12 ' Edit the value to your wanted text font size.
        Dim fsFontStyle As System.Drawing.FontStyle = FontStyle.Regular ' There are 5 font styles: Bold, italic, regular, strikeout, and underline. Edit on your own.
        Dim guTextGUnit As System.Drawing.GraphicsUnit = GraphicsUnit.Point ' Font's unit. Edit on your own.

        ' Usage '
        .Font = New Font(strFontName, iFontSize, fsFontStyle, guTextGUnit) ' Input the valid object's name before dot character.

        ' You are also able to do this using properties window from designer view.

        ' {: Gam3rr0rZ :} '