How to Make a simple calculator in Visual Basic

Mar 16, 2010 12:14 AM
634753162442042288.jpg

If you're new to the Visual Basic IDE, looking to brush up on your VB programming skills, or simply have a burning desire to code a simple calculator, this three-part video lesson is for you.

Here's the code used:

Option Explicit On

Public Class Form1

Dim FirstNumber As Single

Dim SecondNumber As Single

Dim AnswerNumber As Single

Dim ArithmeticProcess As String

Private Sub cmd1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmd1.Click

txtDisplay.Text = txtDisplay.Text & 1

End Sub

Private Sub cmd2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmd2.Click

txtDisplay.Text = txtDisplay.Text & 2

End Sub

Private Sub cmd3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmd3.Click

txtDisplay.Text = txtDisplay.Text & 3

End Sub

Private Sub cmd4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmd4.Click

txtDisplay.Text = txtDisplay.Text & 4

End Sub

Private Sub cmd5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmd5.Click

txtDisplay.Text = txtDisplay.Text & 5

End Sub

Private Sub cmd6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmd6.Click

txtDisplay.Text = txtDisplay.Text & 6

End Sub

Private Sub cmd7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmd7.Click

txtDisplay.Text = txtDisplay.Text & 7

End Sub

Private Sub cmd8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmd8.Click

txtDisplay.Text = txtDisplay.Text & 8

End Sub

Private Sub cmd9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmd9.Click

txtDisplay.Text = txtDisplay.Text & 9

End Sub

Private Sub cmdDecimal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdDecimal.Click

txtDisplay.Text = txtDisplay.Text & "."

End Sub

Private Sub cmdClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Han

Related Articles

635510855891118641.jpg

Real VB.NET Anti-Virus

635510864917367195.jpg

How to Capture Desktop Screen with VB.NET

Comments

No Comments Exist

Be the first, drop a comment!