0% found this document useful (0 votes)
218 views5 pages

Mini Project On Calculator. Source Code:-: Experiment No:-13

Provides full source code for the Calculator Application developed Using Microsoft's Visual Basic Application along with the screenshots of the Output Application.

Uploaded by

Akshay Varma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
218 views5 pages

Mini Project On Calculator. Source Code:-: Experiment No:-13

Provides full source code for the Calculator Application developed Using Microsoft's Visual Basic Application along with the screenshots of the Output Application.

Uploaded by

Akshay Varma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

EXPERIMENT NO :- 13

ROLL NO :- 44

Mini project on Calculator.


Source code :Public Class Form1
Dim Operand1 As Double
Dim Operand2 As Double
Dim count As Integer = 0
Dim le As String = 0
Dim ceflag As Integer = 0
Dim [Operator] As String
Dim memory As Double
Dim Result As Double
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button4.Click
End Sub
Private Sub zero_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
zero.Click
End Sub
Private Sub calculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles calculate.Click
count = count + 1
Operand1 = Val(TextBox1.Text)
If [Operator] = "" Then
Result = Operand1 * 3.14
TextBox1.Text = Result
Else
If IsNumeric(TextBox1.Text) Then
Result = Operand1
Else
Operand2 = TextBox1.Text.Substring(TextBox1.Text.IndexOf([Operator]) + 1)
If [Operator] = "+" Then
Result = Operand1 + Operand2
ElseIf [Operator] = "-" Then
Result = Operand1 - Operand2
ElseIf [Operator] = "/" Then
Result = Operand1 / Operand2
ElseIf [Operator] = "*" Then
Result = Operand1 * Operand2
ElseIf [Operator] = "%" Then
Result = Operand1 Mod Operand2
End If
End If
TextBox1.Text = Result

End If

End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button1.Click, Button2.Click, Button3.Click, Button4.Click, Button5.Click, Button6.Click,
Button7.Click, Button8.Click, Button9.Click, zero.Click, divide.Click, multiply.Click, subtract.Click,
add.Click, moddiv.Click, pi.Click
If TextBox1.Text = "0" Or count >= 1 Then
count = 0
TextBox1.Text = sender.text
ElseIf ceflag = 1 Then
ceflag = 0
TextBox1.Text = TextBox1.Text.Remove(le)
TextBox1.Text = TextBox1.Text.Insert(le, sender.text)
Else
TextBox1.Text = TextBox1.Text + sender.text
End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles MyBase.Load
MaximizeBox = False
TextBox1.Text = "0"
End Sub
Private Sub clear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
clear.Click
TextBox1.Text = "0"
End Sub
Private Sub point_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
point.Click
If InStr(TextBox1.Text, ".") > 0 Then
Exit Sub
Else
TextBox1.Text = TextBox1.Text & "."
End If
End Sub
Private Sub back_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
back.Click
Dim shownum As String
If TextBox1.Text <> "" Then
shownum = TextBox1.Text
shownum = shownum.Remove(shownum.Length - 1, 1)
TextBox1.Text = shownum
If TextBox1.Text = "" Then TextBox1.Text = "0"
End If
End Sub
Private Sub add_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
add.Click
[Operator] = "+"
End Sub
Private Sub subtract_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles subtract.Click
[Operator] = "-"
End Sub

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


Handles multiply.Click
[Operator] = "*"
End Sub
Private Sub divide_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles divide.Click
[Operator] = "/"
End Sub
Private Sub CopyToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles CopyToolStripMenuItem.Click
My.Computer.Clipboard.Clear()
My.Computer.Clipboard.SetText(TextBox1.Text)
End Sub
Private Sub PasteToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles PasteToolStripMenuItem.Click
TextBox1.Text = My.Computer.Clipboard.GetText
End Sub
Private Sub AboutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles AboutToolStripMenuItem.Click
About.Show()
End Sub
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
If (Microsoft.VisualBasic.Asc(e.KeyChar) < 48) _
Or (Microsoft.VisualBasic.Asc(e.KeyChar) > 57) Then
e.Handled = True
End If
If (Microsoft.VisualBasic.Asc(e.KeyChar) = 8) Then
e.Handled = False
End If
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles TextBox1.TextChanged
End Sub
Private Sub cancelentry_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles cancelentry.Click
ceflag = 1
Operand2 = TextBox1.Text.Substring(TextBox1.Text.IndexOf([Operator]) + 1)
le = TextBox1.Text.IndexOf(Operand2)
TextBox1.Text = TextBox1.Text.Remove(le)
TextBox1.Text = TextBox1.Text.Insert(le, 0)
End Sub
Private Sub plus_minus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles plus_minus.Click
TextBox1.Text = -(TextBox1.Text)
End Sub
Private Sub divx_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
divx.Click
count = count + 1
Dim convert As Single

If TextBox1.Text <> 0 Then


convert = 1 / Val(TextBox1.Text)
TextBox1.Text = convert
End If
End Sub
Private Sub squarert_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles squarert.Click
TextBox1.Text = Math.Sqrt(TextBox1.Text)
End Sub
Private Sub moddiv_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles moddiv.Click
[Operator] = "%"
End Sub
Private Sub Button21_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button21.Click
memory = 0
End Sub
Private Sub Button22_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button22.Click
TextBox1.Text = memory
End Sub
Private Sub Button23_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button23.Click
memory = TextBox1.Text
End Sub
Private Sub Button24_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button24.Click
memory = memory + TextBox1.Text
End Sub
Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button10.Click
memory = memory - TextBox1.Text
End Sub
Private Sub pi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
pi.Click
[Operator] = ""
End Sub
Private Sub ViewHelpToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles ViewHelpToolStripMenuItem.Click
Process.Start("http://www.cfd-online.com/Tools/scicalchelp.html")
End Sub
End Class

OUTPUT :-

You might also like