miércoles, 23 de marzo de 2011

Como hacer una calculadora en visual basic

Primero inserta 6 Command Button, 3 TextBox y 3 Label

Los command Button deberan llevar el siguiente
"Caption":

Limpiar, sumar, restar, multiplicar, dividir y salir.

Las 3 Labels deberan ir encima de cada TextBoxt.
Dejalas sin Nombre.

Aqui esta el codigo de una calculadora sencilla en
Visual Basic 6.0

Private Sub Form_Load()
Label1.Caption = "1 Numero"
Label2.Caption = "2 Numero"
Label3.Caption = "Resultado"
End Sub

Private Sub Cerrar_Click()
Unload Me
End Sub

Private Sub Command1_Click()
Text3.Text = Text1.Text * Text2.Text
End Sub

Private Sub Dividir_Click()
Text3.Text = Text1.Text / Text2.Text
End Sub

Private Sub Limpiar_Click()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
End Sub

Private Sub RESTAR_Click() 
Text3.Text = Text1.Text - Text2.Text
End Sub

Private Sub Sumar_Click()
Text3.Text = Val(Text1.Text) + Val(Text2.Text)
End Sub

1 comentario: