Manual de Visual Basic Principiante

 

  Lección: 9

 

Capítulo: Ejercicio 7: Calculadora 3

 

 

Crea un formulario con tres etiquetas, tres cajas de texto, un marco, cuatro botones de opción, tres botones y escribe el siguiente código:

 

El botón Calcular

 

Private Sub Command1_Click()

 

If Option1 = True Then

 

Text3 = Val(Text1) / Val(Text2)

 

ElseIf Option2 = True Then

 

Text3 = Val(Text1) * Val(Text2)

 

ElseIf Option3 = True Then

 

Text3 = Val(Text1) - Val(Text2)

 

ElseIf Option4 = True Then

 

Text3 = Val(Text1) + Val(Text2)

 

End If

 

End Sub

 

El botón Otra Operación

 

Private Sub Command2_Click()

 

Text1 = ""

 

Text2 = ""

 

Text3 = ""

 

Text1.SetFocus

 

End Sub

 

El botón Salir

 

Private Sub Command3_Click()

 

Unload Me

 

End

 

End Sub

 

    Volver al índice!