Calculadora en visual basic

Solo disponible en BuenasTareas
  • Páginas : 2 (253 palabras )
  • Descarga(s) : 0
  • Publicado : 10 de septiembre de 2010
Leer documento completo
Vista previa del texto
Option Explicit
Dim n1, n2 As Long
Dim swpto As Boolean
Dim operador As String

Private Sub Cmdborra_Click(Index As Integer)
txtresult.Text = ""
End Sub

Private Sub cmd0_Click()txtresult.Text = txtresult.Text + "0"
End Sub

Private Sub cmd1_Click()
txtresult.Text = txtresult.Text + "1"
End Sub

Private Sub cmd2_Click()
txtresult.Text = txtresult.Text + "2"
End SubPrivate Sub cmd3_Click()
txtresult.Text = txtresult.Text + "3"
End Sub

Private Sub cmd4_Click()
txtresult.Text = txtresult.Text + "4"
End Sub

Private Sub cmd5_Click()txtresult.Text = txtresult.Text + "5"
End Sub

Private Sub cmd6_Click()
txtresult.Text = txtresult.Text + "6"
End Sub

Private Sub cmd7_Click()
txtresult.Text = txtresult.Text + "7"
End SubPrivate Sub cmd8_Click()
txtresult.Text = txtresult.Text + "8"
End Sub

Private Sub cmd9_Click()
txtresult.Text = txtresult.Text + "9"
End Sub

Private Sub cmdborrar_Click()
txtresult.Text =""
End Sub

Private Sub cmddiv_Click()
n1 = Val(txtresult.Text)
swpto = False
txtresult.Text = ""
operador = "/"
End Sub

Private Sub cmdigual_Click()
n2 = Val(txtresult.Text)If operador = "+" Then
txtresult.Text = n1 + n2
End If
If operador = "-" Then
txtresult.Text = n1 - n2
End If
If operador = "*" Then
txtresult.Text = n1 * n2
End If
If operador ="/" Then
txtresult.Text = n1 / n2
End If

End Sub

Private Sub cmdmulti_Click()
n1 = Val(txtresult.Text)
swpto = False
txtresult.Text = ""
operador = "*"
End Sub

PrivateSub cmdpto_Click(Index As Integer)
If swpto = False Then
txtresult.Text = txtresult.Text + "."
swpto = True
End If
End Sub

Private Sub cmdresta_Click()
n1 = Val(txtresult.Text)swpto = False
txtresult.Text = ""
operador = "-"
End Sub

Private Sub cmdsuma_Click()
n1 = Val(txtresult.Text)
swpto = False
txtresult.Text = ""
operador = "+"
End Sub
tracking img