Esta es la programación completa usada en nuestro proyecto de la calculadora básica desarrollada en Visual Basic
El tema del proyecto: IMPLEMENTACIÓN DE UN PROYECTO DE CALCULADORA (NO DISPONIBLE)
Programación
Dim num1 As Integer
Dim num2 As Integer
Dim op As String
Private Sub Command1_Click()
Text1.Text = Text1.Text & 9
End Sub
Private Sub Command10_Click()
num1 = Text1.Text
Text1.Text = ""
op = "/"
Text1.SetFocus
End Sub
Private Sub Command11_Click()
num1 = Text1.Text
Text1.Text = ""
op = "*"
Text1.SetFocus
End Sub
Private Sub Command12_Click()
num1 = Text1.Text
Text1.Text = ""
op = "-"
Text1.SetFocus
End Sub
Private Sub Command13_Click()
num1 = Text1.Text
Text1.Text = ""
op = "+"
Text1.SetFocus
End Sub
Private Sub Command14_Click()
Text1.Text = Text1.Text & 0
End Sub
Private Sub Command15_Click()
If (num1 = 0) Then
MsgBox ("No se realizó una operación")
Else
num2 = Text1.Text
If op = "+" Then
Text1.Text = num1 + num2
End If
If op = "-" Then
Text1.Text = num1 - num2
End If
If op = "/" Then
Text1.Text = num1 / num2
End If
If op = "*" Then
Text1.Text = num1 * num2
End If
End If
End Sub
Private Sub Command16_Click()
Text1.Text = Text1.Text & "."
End Sub
Private Sub Command17_Click()
Text1.Text = ""
Text1.SetFocus
End Sub
Private Sub Command18_Click()
Text1.Text = ""
Text1.SetFocus
End Sub
Private Sub Command2_Click()
Text1.Text = Text1.Text & 1
End Sub
Private Sub Command3_Click()
Text1.Text = Text1.Text & 2
End Sub
Private Sub Command4_Click()
Text1.Text = Text1.Text & 3
End Sub
Private Sub Command5_Click()
Text1.Text = Text1.Text & 4
End Sub
Private Sub Command6_Click()
Text1.Text = Text1.Text & 5
End Sub
Private Sub Command7_Click()
Text1.Text = Text1.Text & 6
End Sub
Private Sub Command8_Click()
Text1.Text = Text1.Text & 7
End Sub
Private Sub Command9_Click()
Text1.Text = Text1.Text & 8
End Sub
|
No hay comentarios.:
Publicar un comentario