Calculadora Interfaz de La Calculadora

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 6

CALCULADORA

Interfaz de la calculadora

Programación de la calculadora

Public Class Form1


Dim n1, n2 As Double
Dim opera As Integer
Dim resp As Double
Dim com As Integer
Private Sub form_load()

End Sub

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


System.EventArgs) Handles Button14.Click
n1 = Val(TextBox1.Text)
opera = 4
TextBox1.ResetText()
End Sub

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


System.EventArgs) Handles Button12.Click
TextBox1.Text = TextBox1.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
End Sub

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


System.EventArgs) Handles MyBase.Load

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 Button11_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button11.Click
TextBox1.ResetText()
End Sub

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


System.EventArgs) Handles Button10.Click
End
End Sub

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


System.EventArgs) Handles Button17.Click
n1 = Val(TextBox1.Text)
opera = 1
TextBox1.ResetText()
End Sub
Private Sub Button16_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button16.Click
n1 = Val(TextBox1.Text)
opera = 2
TextBox1.ResetText()
End Sub

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


System.EventArgs) Handles Button15.Click
n1 = Val(TextBox1.Text)
opera = 3
TextBox1.ResetText()
End Sub

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


System.EventArgs) Handles Button13.Click
n1 = Val(TextBox1.Text)
opera = 5
TextBox1.ResetText()
If (com < 1) Then
TextBox1.Text = TextBox1.Text & (".")
com = 1
End If
End Sub

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


System.EventArgs) Handles Button18.Click
resp = 0
n2 = Val(TextBox1.Text)
If (opera = 1) Then
resp = n1 * n2
TextBox1.Text = resp

End If
resp = 0
n2 = Val(TextBox1.Text)
If (opera = 4) Then
resp = n1 + n2
TextBox1.Text = resp

End If
resp = 0
n2 = Val(TextBox1.Text)
If (opera = 3) Then
resp = n1 - n2
TextBox1.Text = resp
End If
resp = 0
n2 = Val(TextBox1.Text)
If (opera = 2) Then
If (n2 <> 0) Then
resp = n1 / n2
TextBox1.Text = resp
Else
MsgBox("NO existe divicion en 0", MsgBoxStyle.OkOnly,
("error"))
TextBox1.ResetText()
End If
End If
If (opera = 6) Then
resp = n1 ^ n2
TextBox1.Text = resp
End If

End Sub

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


System.EventArgs) Handles Button25.Click
n1 = Val(TextBox1.Text)
TextBox1.Text = n1 Mod 2

End Sub

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


System.EventArgs) Handles Button19.Click
Dim raiz As Double
resp = 0
n1 = Val(TextBox1.Text)
raiz = Math.Sqrt(n1)
TextBox1.Text = raiz

End Sub

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


System.EventArgs) Handles Button20.Click
n1 = Val(TextBox1.Text)
TextBox1.Text = n1 ^ 2

End Sub

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


System.EventArgs) Handles Button21.Click
n1 = Val(TextBox1.Text)
TextBox1.Text = n1 ^ 3

End Sub

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


System.EventArgs) Handles Button22.Click
n1 = Val(TextBox1.Text)
opera = 5
TextBox1.Text = " "

End Sub

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


System.EventArgs) Handles Button23.Click
n1 = Val(TextBox1.Text)
TextBox1.Text = 1 / n1

End Sub
Private Sub Button24_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button24.Click
n1 = Val(TextBox1.Text)
TextBox1.Text = 0 - n1

End Sub

Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object,


ByVal e As System.EventArgs)

End Sub

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


System.EventArgs) Handles Button26.Click
Dim coseno, Dec As Double
n1 = Val(TextBox1.Text)
Dec = 180 / n1
coseno = Math.Cos(Math.PI / Dec)
TextBox1.Text = coseno

End Sub

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


System.EventArgs) Handles Button27.Click
Dim pi As Double
n1 = Val(TextBox1.Text)
pi = Math.PI
TextBox1.Text = pi
End Sub

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


System.EventArgs) Handles Button28.Click
Dim seno, dec As Double
n1 = Val(TextBox1.Text)
dec = 180 / n1
seno = Math.Sin(Math.PI / dec)
TextBox1.Text = seno
End Sub

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


System.EventArgs) Handles Button29.Click
Dim tangente, dec As Double
n1 = Val(TextBox1.Text)
dec = 180 / n1
tangente = Math.Tan(Math.PI / dec)
TextBox1.Text = tangente
End Sub

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


System.EventArgs) Handles Button30.Click
Dim fac As Double
fac = 1
n1 = Val(TextBox1.Text)
While (n1 <> 0)
fac = fac * n1
n1 = n1 - 1
TextBox1.Text = fac
End While

End Sub

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


System.EventArgs) Handles Button31.Click
Dim text1 As String
text1 = TextBox1.Text
If (Len(Text1) <> 0) Then
TextBox1.Text = Mid(text1, 1, Len(text1) - 1)
Else
TextBox1.Text = text1

End If
End Sub
End Class

You might also like