Visual Basic - Codigo de una calculadora.

Life is soft - evento anual de software empresarial
 
Vista:

Codigo de una calculadora.

Publicado por Pablo (3 intervenciones) el 05/07/2006 18:51:03
Buenos dias, me gustaria que alguien me pueda explicar este codigo, yo voy a poner entre
Signos de Admiracion ( ! ¡ ) Lo que no entienda.

Otra cosa muy importante es explicar que es cada objeto:
Borrar------Borra el contenido de SegundoOperando MostrarResultado y PrimerOperando

PrimerOperando------Textbox donde se incluye el primer numero a calcular maximo 4
sifras.

Segundo Operando-----Textbox donde se incluye el segundo numero a calcular maximo 4 sifras.

MostrarResultado------Label que muestra el resultado de la operacion entre primer operando y segundo operando.

Me gustaria que alguien se tome el atrevimiento de explicar paso a paso cada linea de codigo, Yo entiendo muchas cosas, pero muchas cosas tambien no las entiendo, Y seria un poco calamitoso mesclar lo que no entiendo con el codigo, asi que pido que alguien se tome la amabilidad de mostrarmelo.Gracias,Voy a consultar este treadh todos los dias.

Pablo

Codigo de calculadora:

Private Sub Borrar_Click()
PrimerOperando.Text = ""
SegundoOperando.Text = ""
MostrarResultado.Caption = 0
PrimerOperando.SetFocus
End Sub

Private Sub Calcular_Click()
Dim Operador As String
If PrimerOperando.Text = "" Or SegundoOperando.Text = "" Then
MsgBox ("Falta algún operando")
Exit Sub
End If
If Sumar.Value = True Then MostrarResultado.Caption = Val(PrimerOperando.Text) + Val(SegundoOperando.Text)
If Restar.Value = True Then MostrarResultado.Caption = Val(PrimerOperando.Text) - Val(SegundoOperando.Text)
If Multiplicar.Value = True Then MostrarResultado.Caption = Val(PrimerOperando.Text) * Val(SegundoOperando.Text)
If Dividir.Value = True Then
If Val(SegundoOperando.Text) = 0 Then
MsgBox ("No se puede dividir entre 0")
Exit Sub
End If
MostrarResultado.Caption = Val(PrimerOperando.Text) / Val(SegundoOperando.Text)
End If
If Añadir.Text = "Añadir a la lista" Then
If Operacion.Value = True Then
If Sumar.Value = True Then Operador = "+"
If Restar.Value = True Then Operador = "-"
If Multiplicar.Value = True Then Operador = "*"
If Dividir.Value = True Then Operador = "/"
ListaOperaciones.AddItem PrimerOperando.Text & Operador & SegundoOperando.Text & "=" & MostrarResultado.Caption
Else
ListaOperaciones.AddItem MostrarResultado.Caption
End If
End If
End Sub
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder