0% found this document useful (0 votes)
29 views4 pages

Scientific

This document contains the code for a calculator application with multiple modes and functions. It includes code to handle button clicks to add numbers, perform arithmetic operations, convert between units, and call scientific functions. The code defines variables to store input values and operations. It also contains code to change the layout and size of the calculator depending on the selected mode.

Uploaded by

hailu badye
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)
29 views4 pages

Scientific

This document contains the code for a calculator application with multiple modes and functions. It includes code to handle button clicks to add numbers, perform arithmetic operations, convert between units, and call scientific functions. The code defines variables to store input values and operations. It also contains code to change the layout and size of the calculator depending on the selected mode.

Uploaded by

hailu badye
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/ 4

Public Class Form1

Dim f As Double
Dim s As Double
Dim a As Double
Dim op As String
Dim n As Int64

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


Handles Button1.Click, Button3.Click, Button2.Click, Button9.Click, Button8.Click,
Button7.Click, Button24.Click, Button22.Click, Button15.Click, Button14.Click,
Button13.Click
Dim b As Button = sender
If Label1.Text = "0" Then
Label1.Text = b.Text
Else
Label1.Text = Label1.Text + b.Text
End If
End Sub

Private Sub Button23_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button23.Click
Label1.Text = "0"
End Sub

Private Sub Button26_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button26.Click
Label1.Text = "0"
Label2.Text = " "
End Sub

Private Sub arithmetic_function(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button6.Click, Button21.Click, Button19.Click, Button18.Click,
Button12.Click, Button4.Click
Dim ops As Button = sender
f = Label1.Text
Label2.Text = Label1.Text
Label1.Text = ""
op = ops.Text
Label2.Text = Label2.Text + " " + op
End Sub

Private Sub arithmetc_function(ByVal sender As System.Object, ByVal e As


System.EventArgs)

End Sub

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

End Sub

Private Sub Button25_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button25.Click
s = Label1.Text
If op = "+" Then
a = f + s
Label1.Text = a
Label2.Text = ""
ElseIf op = "-" Then
a = f - s
Label1.Text = a
Label2.Text = ""
ElseIf op = "/" Then
a = f / s
Label1.Text = a
Label2.Text = ""
ElseIf op = "*" Then
a = f * s
Label1.Text = a
Label2.Text = ""
ElseIf op = "Mod" Then
a = f Mod s
Label1.Text = a
Label2.Text = ""
ElseIf op = "Exp" Then
a = f ^ s
Label1.Text = a
Label2.Text = ""
End If
End Sub

Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button10.Click
If Int64.TryParse(Label1.Text, n) Then
Label1.Text = Convert.ToString(n, 2)
Else
Label1.Text = ""
End If
End Sub

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


Handles Button5.Click
a = Math.Sin(Label1.Text)
Label1.Text = a
Label2.Text = ""
End Sub

Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button11.Click
a = Math.Cos(Label1.Text)
Label1.Text = a
Label2.Text = ""
End Sub

Private Sub Button17_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button17.Click
a = Math.Tan(Label1.Text)
Label1.Text = a
Label2.Text = ""
End Sub

Private Sub Button16_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button16.Click
a = Math.Log(Label1.Text)
Label1.Text = a
Label2.Text = ""
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles ComboBox1.SelectedIndexChanged
Me.Height = 423
Me.Width = 269
Button18.Width = 112
Label1.Text = 229

ComboBox1.Text = "choose one ..."


ComboBox1.Items.Add("Celsius to Fraheniet")
ComboBox1.Items.Add("fraheniet to celcius")
ComboBox1.Items.Add("Miles to Kilometres")
ComboBox1.Items.Add("Kilometres to Miles")
ComboBox1.Items.Add("Centemetres to Metres")
End Sub

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


Handles ComboBox1.Click

End Sub

Private Sub Button28_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button28.Click
Dim Convt As Double
If ComboBox1.Text = "Celsius to Fraheniet" Then
Convt = (9 / 5 * TextBox1.Text) + 32
TextBox2.Text = (Convt) & "Fraheniet"
ElseIf ComboBox1.Text = "fraheniet to celcius" Then
Convt = 5 / 9 * (TextBox1.Text - 32)
TextBox2.Text = Convt & "celcius"
ElseIf ComboBox1.Text = "Kilometres to Miles" Then
Convt = (TextBox2.Text / 1.609344)
TextBox2.Text = Convt & -"Miles"
ElseIf ComboBox1.Text = "Kilometres to Miles" Then
Convt = (TextBox2.Text / 1.609344)
TextBox2.Text = Convt & -"Kilometres"
ElseIf ComboBox1.Text = "choose one ..." Or TextBox2.Text = "" Then
MsgBox("Select a unit of conversation", "Calculator plus", vbInformation)
End If
End Sub

Private Sub ScientificToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e


As System.EventArgs) Handles ScientificToolStripMenuItem.Click
Me.Height = 423
Me.Width = 393
Button18.Width = 238
Label1.Text = 355
End Sub

Private Sub UnitConversationToolStripMenuItem_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles UnitConversationToolStripMenuItem.Click
Me.Height = 423
Me.Width = 393
Button18.Width = 238
Label1.Text = 355
End Sub
Private Sub StandardToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles StandardToolStripMenuItem.Click
Me.Height = 423
Me.Width = 269
Button18.Width = 112
Label1.Text = 229
End Sub
End Class

You might also like