Today i will teach you how to make a calculator in VB.NET , making your own calculator would be awesome.
13 . then copy and paste this bunch of code
14. enjoy
I did a tutorial about making an advanced calculator, you would love it : How To Make A Advance Calculator In VB.NET
- open visual basic 2008 or visual basic 2010
- create a new project
- windows form/console application
- change your form size to 223, 274
- go to form1 properties and text name it whatever you want (calculator)
- add 18 buttons from the tool box
- add a textbox
- click textbox then properties and multiline and make it true
- click text box and properties and click font and make the font little bigger
- make the text box little bigger
- now change the button text to look like this
13 . then copy and paste this bunch of code
13 . now debugOption
Explicit
On
Public
Class
Form1
'Author : Mohamed Shimran
Dim
FirstNumber
As
Single
Dim
SecondNumber
As
Single
Dim
AnswerNumber
As
Single
Dim
ArithmeticProcess
As
String
Private
Sub
Button1_Click(
ByVal
sender
As
System.
Object
,
ByVal
e
As
System.EventArgs)
Handles
Button1.Click
TextBox1.Text = TextBox1.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
End
Sub
Private
Sub
Button3_Click(
ByVal
sender
As
System.
Object
,
ByVal
e
As
System.EventArgs)
Handles
Button3.Click
TextBox1.Text = TextBox1.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
End
Sub
Private
Sub
Button5_Click(
ByVal
sender
As
System.
Object
,
ByVal
e
As
System.EventArgs)
Handles
Button5.Click
TextBox1.Text = TextBox1.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
End
Sub
Private
Sub
Button7_Click(
ByVal
sender
As
System.
Object
,
ByVal
e
As
System.EventArgs)
Handles
Button7.Click
TextBox1.Text = TextBox1.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
End
Sub
Private
Sub
Button9_Click(
ByVal
sender
As
System.
Object
,
ByVal
e
As
System.EventArgs)
Handles
Button9.Click
TextBox1.Text = TextBox1.Text & 9
End
Sub
Private
Sub
Button10_Click(
ByVal
sender
As
System.
Object
,
ByVal
e
As
System.EventArgs)
Handles
Button10.Click
TextBox1.Text = TextBox1.Text & 0
End
Sub
Private
Sub
Button11_Click(
ByVal
sender
As
System.
Object
,
ByVal
e
As
System.EventArgs)
Handles
Button11.Click
TextBox1.Text = TextBox1.Text &
"."
End
Sub
Private
Sub
Button13_Click(
ByVal
sender
As
System.
Object
,
ByVal
e
As
System.EventArgs)
Handles
Button13.Click
FirstNumber = Val(TextBox1.Text)
TextBox1.Text =
"0"
ArithmeticProcess =
"+"
End
Sub
Private
Sub
Button14_Click(
ByVal
sender
As
System.
Object
,
ByVal
e
As
System.EventArgs)
Handles
Button14.Click
FirstNumber = Val(TextBox1.Text)
TextBox1.Text =
"0"
ArithmeticProcess =
"-"
End
Sub
Private
Sub
Button15_Click(
ByVal
sender
As
System.
Object
,
ByVal
e
As
System.EventArgs)
Handles
Button15.Click
FirstNumber = Val(TextBox1.Text)
TextBox1.Text =
"0"
ArithmeticProcess =
"X"
End
Sub
Private
Sub
Button16_Click(
ByVal
sender
As
System.
Object
,
ByVal
e
As
System.EventArgs)
Handles
Button16.Click
FirstNumber = Val(TextBox1.Text)
TextBox1.Text =
"0"
ArithmeticProcess =
"/"
End
Sub
Private
Sub
Button18_Click(
ByVal
sender
As
System.
Object
,
ByVal
e
As
System.EventArgs)
Handles
Button18.Click
SecondNumber = Val(TextBox1.Text)
If
ArithmeticProcess =
"+"
Then
AnswerNumber = FirstNumber + SecondNumber
End
If
If
ArithmeticProcess =
"-"
Then
AnswerNumber = FirstNumber - SecondNumber
End
If
If
ArithmeticProcess =
"X"
Then
AnswerNumber = FirstNumber * SecondNumber
End
If
If
ArithmeticProcess =
"/"
Then
AnswerNumber = FirstNumber / SecondNumber
End
If
TextBox1.Text = AnswerNumber
End
Sub
End
Class
14. enjoy
I did a tutorial about making an advanced calculator, you would love it : How To Make A Advance Calculator In VB.NET