·
First start Visual Basic Studio
2008 Express Edition
·
Then press Ctrl+n to start a new
project
·
Choose Windows Form Application
format and press OK
·
Now double click on the Form1
box
·
Now paste the following code
after deleting everything written in the place that opens.
Public Class Form1
Dim x As Double
Dim z As String
Dim y As Double
Private Sub Button10_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles Button10.Click
TextBox1.Text = (TextBox1.Text) + "0"
TextBox2.Text = TextBox2.Text + "0"
End Sub
Private Sub Button1_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
TextBox1.Text = (TextBox1.Text) + "1"
TextBox2.Text = TextBox2.Text + "1"
End Sub
Private Sub Button2_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
TextBox1.Text = (TextBox1.Text) + "2"
TextBox2.Text = TextBox2.Text + "2"
End Sub
Private Sub Button3_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles Button3.Click
TextBox1.Text = (TextBox1.Text) + "3"
TextBox2.Text = TextBox2.Text + "3"
End Sub
Private Sub Button4_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles Button4.Click
TextBox1.Text = (TextBox1.Text) + "4"
TextBox2.Text = TextBox2.Text + "4"
End Sub
Private Sub Button5_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles Button5.Click
TextBox1.Text = (TextBox1.Text) + "5"
TextBox2.Text = TextBox2.Text + "5"
End Sub
Private Sub Button6_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles Button6.Click
TextBox1.Text = (TextBox1.Text) + "6"
TextBox2.Text = TextBox2.Text + "6"
End Sub
Private Sub Button7_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles Button7.Click
TextBox1.Text = (TextBox1.Text) + "7"
TextBox2.Text = TextBox2.Text + "7"
End Sub
Private Sub Button8_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles Button8.Click
TextBox1.Text = (TextBox1.Text) + "8"
TextBox2.Text = TextBox2.Text + "8"
End Sub
Private Sub Button9_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles Button9.Click
TextBox1.Text = (TextBox1.Text) + "9"
TextBox2.Text = TextBox2.Text + "9"
End Sub
Private Sub Button11_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles Button11.Click
TextBox1.Text = (TextBox1.Text) + "."
TextBox2.Text = TextBox2.Text + "."
End Sub
Private Sub Button16_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles Button16.Click
y = Val(TextBox1.Text)
If z = "+" Then
TextBox1.Text = x + y
End If
If z = "-" Then
TextBox1.Text = x - y
End If
If z = "/" Then
TextBox1.Text = x / y
End If
If z = "*" Then
TextBox1.Text = x * y
End If
x = Val(TextBox1.Text)
End Sub
Private Sub Button17_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles Button17.Click
y = Val(TextBox1.Text)
If z = "+" Then
TextBox1.Text = x + y
End If
If z = "-" Then
TextBox1.Text = x - y
End If
If z = "/" Then
TextBox1.Text = x / y
End If
If z = "*"
Then
TextBox1.Text = x * y
End If
TextBox1.Text = 1 /
(Val(TextBox1.Text))
TextBox2.Text = "1/(" + TextBox2.Text + ")"
End Sub
Private Sub Button18_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles Button18.Click
y = Val(TextBox1.Text)
If z = "+" Then
TextBox1.Text = x + y
End If
If z = "-" Then
TextBox1.Text = x - y
End If
If z = "/" Then
TextBox1.Text = x / y
End If
If z = "*" Then
TextBox1.Text = x * y
End If
TextBox1.Text = (Val(TextBox1.Text)) ^
(1 / 2)
TextBox2.Text = "√(" + TextBox2.Text + ")"
End Sub
Private Sub Button12_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles Button12.Click
y = Val(TextBox1.Text)
If z = "+" Then
TextBox1.Text = x + y
End If
If z = "-" Then
TextBox1.Text = x - y
End If
If z = "/" Then
TextBox1.Text = x / y
End If
If z = "*" Then
TextBox1.Text = x * y
End If
x = Val(TextBox1.Text)
TextBox1.Text = ""
z = "+"
TextBox2.Text = TextBox2.Text + "+"
End Sub
Private Sub Button13_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles Button13.Click
y = Val(TextBox1.Text)
If z = "+" Then
TextBox1.Text = x + y
End If
If z = "-" Then
TextBox1.Text = x - y
End If
If z = "/" Then
TextBox1.Text = x / y
End If
If z = "*" Then
TextBox1.Text = x * y
End If
x = Val(TextBox1.Text)
TextBox1.Text = ""
z = "-"
TextBox2.Text = TextBox2.Text + "-"
End Sub
Private Sub Button14_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles Button14.Click
y = Val(TextBox1.Text)
If z = "+" Then
TextBox1.Text = x + y
End If
If z = "-" Then
TextBox1.Text = x - y
End If
If z = "/" Then
TextBox1.Text = x / y
End If
If z = "*" Then
TextBox1.Text = x * y
End If
x = Val(TextBox1.Text)
TextBox1.Text = ""
z = "/"
TextBox2.Text = TextBox2.Text + "/"
End Sub
Private Sub Button15_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles Button15.Click
y = Val(TextBox1.Text)
If z = "+" Then
TextBox1.Text = x + y
End If
If z = "-" Then
TextBox1.Text = x - y
End If
If z = "/" Then
TextBox1.Text = x / y
End If
If z = "*" Then
TextBox1.Text = x * y
End If
x = Val(TextBox1.Text)
TextBox1.Text = ""
z = "*"
TextBox2.Text = TextBox2.Text + "*"
End Sub
Private Sub Button19_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles Button19.Click
TextBox1.Text = ""
TextBox2.Text = ""
x = 0
y = 0
z = ""
End Sub
Private Sub Button20_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles Button20.Click
Me.Close()
End Sub
End Class
·
Click
on Ctrl+Shift+S
·
Enter
name “Calculator” in the name bar. Don’t close the vb window
·
Click
on the Start button.
·
Enter
the name “Visual Studio 2008” in the search bar of the start window.
·
Open
the folder
·
From
there go to projects>calculator>calculator [yes, two times]
·
Double
click on Form1.Designer.vb and close the folder.
·
Open
the vb window
·
You
will find a new tab there named Form1.Designer.vb
·
Delete
everything written there and paste the following code.
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()>
_
Partial Class Form1
Inherits
System.Windows.Forms.Form
'Form overrides dispose
to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub
Dispose(ByVal disposing As Boolean)
Try
If
disposing AndAlso components IsNot Nothing Then
components.Dispose()
End
If
Finally
MyBase.Dispose(disposing)
End Try
End Sub
'Required by the
Windows Form Designer
Private
components As System.ComponentModel.IContainer
'NOTE: The
following procedure is required by the Windows Form Designer
'It can be
modified using the Windows Form Designer.
'Do not modify it
using the code editor.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Me.TextBox1
= New System.Windows.Forms.TextBox
Me.Button1
= New System.Windows.Forms.Button
Me.Button2
= New System.Windows.Forms.Button
Me.Button3
= New System.Windows.Forms.Button
Me.Button4
= New System.Windows.Forms.Button
Me.Button5
= New System.Windows.Forms.Button
Me.Button6
= New System.Windows.Forms.Button
Me.Button7
= New System.Windows.Forms.Button
Me.Button8
= New System.Windows.Forms.Button
Me.Button9
= New System.Windows.Forms.Button
Me.Button10 = New
System.Windows.Forms.Button
Me.Button11
= New System.Windows.Forms.Button
Me.Button12
= New System.Windows.Forms.Button
Me.Button13
= New System.Windows.Forms.Button
Me.Button14
= New System.Windows.Forms.Button
Me.Button15
= New System.Windows.Forms.Button
Me.Button16
= New System.Windows.Forms.Button
Me.Button17
= New System.Windows.Forms.Button
Me.Button18
= New System.Windows.Forms.Button
Me.Button19
= New System.Windows.Forms.Button
Me.Button20
= New System.Windows.Forms.Button
Me.TextBox2
= New System.Windows.Forms.TextBox
Me.SuspendLayout()
'
'TextBox1
'
Me.TextBox1.Location
= New System.Drawing.Point(10, 33)
Me.TextBox1.Name
= "TextBox1"
Me.TextBox1.Size
= New System.Drawing.Size(169, 20)
Me.TextBox1.TabIndex
= 0
Me.TextBox1.TextAlign
= System.Windows.Forms.HorizontalAlignment.Right
'
'Button1
'
Me.Button1.Location
= New System.Drawing.Point(10, 129)
Me.Button1.Name
= "Button1"
Me.Button1.Size
= New System.Drawing.Size(29, 29)
Me.Button1.TabIndex
= 1
Me.Button1.Text
= "1"
Me.Button1.UseVisualStyleBackColor
= True
'
'Button2
'
Me.Button2.Location
= New System.Drawing.Point(45, 129)
Me.Button2.Name
= "Button2"
Me.Button2.Size
= New System.Drawing.Size(29, 29)
Me.Button2.TabIndex
= 2
Me.Button2.Text
= "2"
Me.Button2.UseVisualStyleBackColor
= True
'
'Button3
'
Me.Button3.Location
= New System.Drawing.Point(80, 129)
Me.Button3.Name
= "Button3"
Me.Button3.Size
= New System.Drawing.Size(29, 29)
Me.Button3.TabIndex
= 3
Me.Button3.Text
= "3"
Me.Button3.UseVisualStyleBackColor
= True
'
'Button4
'
Me.Button4.Location
= New System.Drawing.Point(10, 94)
Me.Button4.Name
= "Button4"
Me.Button4.Size
= New System.Drawing.Size(29, 29)
Me.Button4.TabIndex
= 4
Me.Button4.Text
= "4"
Me.Button4.UseVisualStyleBackColor
= True
'
'Button5
'
Me.Button5.Location
= New System.Drawing.Point(45, 94)
Me.Button5.Name
= "Button5"
Me.Button5.Size
= New System.Drawing.Size(29, 29)
Me.Button5.TabIndex
= 5
Me.Button5.Text
= "5"
Me.Button5.UseVisualStyleBackColor
= True
'
'Button6
'
Me.Button6.Location
= New System.Drawing.Point(80, 94)
Me.Button6.Name
= "Button6"
Me.Button6.Size
= New System.Drawing.Size(29, 29)
Me.Button6.TabIndex
= 6
Me.Button6.Text
= "6"
Me.Button6.UseVisualStyleBackColor
= True
'
'Button7
'
Me.Button7.Location
= New System.Drawing.Point(10, 58)
Me.Button7.Name
= "Button7"
Me.Button7.Size
= New System.Drawing.Size(29, 29)
Me.Button7.TabIndex
= 7
Me.Button7.Text
= "7"
Me.Button7.UseVisualStyleBackColor
= True
'
'Button8
'
Me.Button8.Location
= New System.Drawing.Point(45, 58)
Me.Button8.Name
= "Button8"
Me.Button8.Size
= New System.Drawing.Size(29, 29)
Me.Button8.TabIndex
= 8
Me.Button8.Text
= "8"
Me.Button8.UseVisualStyleBackColor
= True
'
'Button9
'
Me.Button9.Location
= New System.Drawing.Point(80, 58)
Me.Button9.Name
= "Button9"
Me.Button9.Size
= New System.Drawing.Size(29, 29)
Me.Button9.TabIndex
= 9
Me.Button9.Text
= "9"
Me.Button9.UseVisualStyleBackColor
= True
'
'Button10
'
Me.Button10.Location
= New System.Drawing.Point(10, 164)
Me.Button10.Name
= "Button10"
Me.Button10.Size
= New System.Drawing.Size(64, 29)
Me.Button10.TabIndex
= 10
Me.Button10.Text
= "0"
Me.Button10.UseVisualStyleBackColor
= True
'
'Button11
'
Me.Button11.Location
= New System.Drawing.Point(80, 164)
Me.Button11.Name
= "Button11"
Me.Button11.Size
= New System.Drawing.Size(29, 29)
Me.Button11.TabIndex
= 11
Me.Button11.Text
= "."
Me.Button11.UseVisualStyleBackColor
= True
'
'Button12
'
Me.Button12.Location
= New System.Drawing.Point(115, 59)
Me.Button12.Name
= "Button12"
Me.Button12.Size
= New System.Drawing.Size(29, 29)
Me.Button12.TabIndex
= 12
Me.Button12.Text
= "+"
Me.Button12.UseVisualStyleBackColor
= True
'
'Button13
'
Me.Button13.Location
= New System.Drawing.Point(115, 94)
Me.Button13.Name
= "Button13"
Me.Button13.Size
= New System.Drawing.Size(29, 29)
Me.Button13.TabIndex
= 13
Me.Button13.Text
= "-"
Me.Button13.UseVisualStyleBackColor
= True
'
'Button14
'
Me.Button14.Location
= New System.Drawing.Point(115, 129)
Me.Button14.Name
= "Button14"
Me.Button14.Size
= New System.Drawing.Size(29, 29)
Me.Button14.TabIndex
= 14
Me.Button14.Text
= "/"
Me.Button14.UseVisualStyleBackColor
= True
'
'Button15
'
Me.Button15.Location
= New System.Drawing.Point(115, 164)
Me.Button15.Name
= "Button15"
Me.Button15.Size
= New System.Drawing.Size(29, 29)
Me.Button15.TabIndex
= 15
Me.Button15.Text
= "*"
Me.Button15.UseVisualStyleBackColor
= True
'
'Button16
'
Me.Button16.Location
= New System.Drawing.Point(150, 129)
Me.Button16.Name
= "Button16"
Me.Button16.Size
= New System.Drawing.Size(29, 64)
Me.Button16.TabIndex
= 16
Me.Button16.Text
= "="
Me.Button16.UseVisualStyleBackColor
= True
'
'Button17
'
Me.Button17.Font
= New System.Drawing.Font("Microsoft Sans Serif", 6.75!,
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Button17.Location
= New System.Drawing.Point(150, 94)
Me.Button17.Name
= "Button17"
Me.Button17.Size
= New System.Drawing.Size(29, 29)
Me.Button17.TabIndex
= 17
Me.Button17.Text
= "1/x"
Me.Button17.UseVisualStyleBackColor
= True
'
'Button18
'
Me.Button18.Location
= New System.Drawing.Point(150, 59)
Me.Button18.Name
= "Button18"
Me.Button18.Size
= New System.Drawing.Size(29, 29)
Me.Button18.TabIndex
= 18
Me.Button18.Text
= "√"
Me.Button18.UseVisualStyleBackColor
= True
'
'Button19
'
Me.Button19.Location
= New System.Drawing.Point(45, 199)
Me.Button19.Name
= "Button19"
Me.Button19.Size
= New System.Drawing.Size(47, 23)
Me.Button19.TabIndex
= 19
Me.Button19.Text
= "Reset"
Me.Button19.UseVisualStyleBackColor
= True
'
'Button20
'
Me.Button20.Location
= New System.Drawing.Point(98, 199)
Me.Button20.Name
= "Button20"
Me.Button20.Size
= New System.Drawing.Size(40, 23)
Me.Button20.TabIndex
= 20
Me.Button20.Text
= "Exit"
Me.Button20.UseVisualStyleBackColor
= True
'
'TextBox2
'
Me.TextBox2.Location
= New System.Drawing.Point(10, 11)
Me.TextBox2.Name
= "TextBox2"
Me.TextBox2.Size
= New System.Drawing.Size(169, 20)
Me.TextBox2.TabIndex
= 21
Me.TextBox2.TextAlign
= System.Windows.Forms.HorizontalAlignment.Right
'
'Form1
'
Me.AutoScaleDimensions
= New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode
= System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize
= New System.Drawing.Size(189, 232)
Me.Controls.Add(Me.TextBox2)
Me.Controls.Add(Me.Button20)
Me.Controls.Add(Me.Button19)
Me.Controls.Add(Me.Button18)
Me.Controls.Add(Me.Button17)
Me.Controls.Add(Me.Button16)
Me.Controls.Add(Me.Button15)
Me.Controls.Add(Me.Button14)
Me.Controls.Add(Me.Button13)
Me.Controls.Add(Me.Button12)
Me.Controls.Add(Me.Button11)
Me.Controls.Add(Me.Button10)
Me.Controls.Add(Me.Button9)
Me.Controls.Add(Me.Button8)
Me.Controls.Add(Me.Button7)
Me.Controls.Add(Me.Button6)
Me.Controls.Add(Me.Button5)
Me.Controls.Add(Me.Button4)
Me.Controls.Add(Me.Button3)
Me.Controls.Add(Me.Button2)
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.TextBox1)
Me.Name
= "Form1"
Me.Text
= "Calculator"
Me.TopMost
= True
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
Friend WithEvents TextBox1 As
System.Windows.Forms.TextBox
Friend WithEvents Button1 As
System.Windows.Forms.Button
Friend WithEvents Button2 As
System.Windows.Forms.Button
Friend WithEvents Button3 As
System.Windows.Forms.Button
Friend WithEvents Button4 As
System.Windows.Forms.Button
Friend WithEvents Button5 As
System.Windows.Forms.Button
Friend WithEvents Button6 As
System.Windows.Forms.Button
Friend WithEvents Button7 As
System.Windows.Forms.Button
Friend WithEvents Button8 As
System.Windows.Forms.Button
Friend WithEvents Button9 As
System.Windows.Forms.Button
Friend WithEvents Button10 As
System.Windows.Forms.Button
Friend WithEvents Button11 As
System.Windows.Forms.Button
Friend WithEvents Button12 As
System.Windows.Forms.Button
Friend WithEvents Button13 As
System.Windows.Forms.Button
Friend WithEvents Button14 As
System.Windows.Forms.Button
Friend WithEvents Button15 As
System.Windows.Forms.Button
Friend WithEvents Button16 As
System.Windows.Forms.Button
Friend WithEvents Button17 As
System.Windows.Forms.Button
Friend WithEvents Button18 As
System.Windows.Forms.Button
Friend WithEvents Button19 As
System.Windows.Forms.Button
Friend WithEvents Button20 As
System.Windows.Forms.Button
Friend WithEvents TextBox2 As
System.Windows.Forms.TextBox
End Class
·
Click
on the green triangle at the top part of vb window.
·
You
will see the calculator on your screen. It does not support BODMAS function
(even your windows calc doesn’t support that!) or keyboard input.
·
You
can use the calculator just like a normal one.
·
You
can convert this file to an exe too!
·
Enter
this in the windows searchbar: “Visual Studio
2008\Projects\Calculator\Calculator\bin\Debug”
·
You
will see a file named calculator with an icon like this one:
·
Copy
that file to your desktop
·
You
can now use the calculator just by double clicking the icon
·
Thank
You!