viernes, 28 de diciembre de 2018

VISUAL BASIC CLASE #3 : CALCULADORA


                                    PROYECTO #3

                              CALCULADORA       
 
CODIFICACIÓN 

Dim Opera As Byte
Dim Num1 Num2 Resp As Double

Private Sub Division_Click(Index As Integer)
Num1 = Val(Mostrar.Text)
Opera = 1
Mostrar.Text = " "
End Sub

Private Sud Form.Load()
Num1 = 0
Num2 = 0
End Sub

Private Sub Igual_Click(Index As Integer)
Resp = 0
Num2 = VAl(Mostrar.Text)
If Opera = 1then
Resp = Num1 + Num2
End If
If Opera=2 then
Resp = Num1 - Num2
End If
If Opera = 3 then
Resp=Num1 * Num2
End If
If Opera = 4 then
If Num2 = 0 then
MsgBox "NO SE PUEDE DIVIDIR ENTRE CERO"
Exit Sub
End If
Resp=Num1 / Num2
End If
Mostrar.Text = Resp
End Sub

Private Sub Limpiar_Click()
Mostrar.Text = " "
Num1 = 0
Num2 = 0
Resp = 0
End Sub

Private Sub Multiplicacion_Click(Index As Innteger)
Num1 = Val(Mostrar.Text)
Opera = 3
Mostrar.Text=" "
End Sub

Private Sub N0_Click(Index As Integer)
Mostrar.Text = Mostrar.Text+Str(0)
End Sub


Private Sub N1_Click(Index As Integer)
Mostrar.Text = Mostrar.Text+Str(1)
End Sub

Private Sub N2_Click(Index As Integer)
Mostrar.Text=Mostrar.Text+Str(2)
End Sub

Private Sub N3_Click(Index As Integer)
Mostrar.Text = Mostrar.Text + Str(3)
End Sub

Private Sub N4_Click(Index As Integer)
Mostrar.Text = Mostrar.Text + Str(4)
End Sub

Private Sub N5_Click(Index As Integer)
Mostrar.Text = Mostrar.Text + Str(5)
End Sub

Private Sub N6_Click(Index As Integer)
Mostrar.Text = Mostrar.Text + Str(6)
End Sub

Private Sub N7_Click(Index As Integer)
Mostrar.Text = Mostrar.Text + Str(7)
End Sub

Private Sub N8_Click(Index As Integer)
Mostrar.Text = Mostrar.Text + Str(8)
End Sub

Private Sub N9_Click(Index As Integer)
Mostrar.Text = Mostrar.Text + Str(9)
End Sub


Private Sub Resta_Click(Index As Integer)
Num1 = Val (Mostrar.Text)
Opera = 2
Mostrar.Text = " "
End Sub

Private Sub Salir_Click
End
End Sub

Private Sub Suma_Click(Index As Integer)
Num1 = Val (Mostrar.Text)
Opera = 2
Mostrar.Text = " "
End Sub

2 comentarios: