jueves, 24 de septiembre de 2009

Calculadora


Dim bsuma, bresta, bmulti, bdivicion As Boolean
Dim divicion As Single
Dim suma, resta, multi, resultado As Integer
Private Sub command1_click()
Text1 = Text1 + Str(1)
End Sub
Private Sub Command10_Click()
Text1 = Text1 + Str(0)
End Sub
Private Sub Command11_Click()
suma = Val(Text1)Text1 = ""
bsuma = True
End Sub

Private Sub Command12_Click()
resta = Val(Text1)Text1 = ""
bresta = True
End Sub

Private Sub Command13_Click()
multi = Val(Text1)Text1 = ""
bmulti = True
End Sub

Private Sub command15_click()
If bsuma = True Then
resultado = resultado + Val(Text1)
suma = suma + Val(Text1)
Text1 = Str(suma)
bsuma = False
End If
If bresta = True Then
resultado = resultado + Val(Text1)
resta = resta - Val(Text1)
Text1 = Str(resta)
bresta = False
End If
If bmulti = True Then
resultado = resultado + Val(Text1)
multi = multi * Val(Text1)
Text1 = Str(multi)
bmulti = False
End If
If bdivicion = True Then
resultado = resultado + Val(Text1)
divicion = divicion / Val(Text1)
Text1 = Str(divicion)
bdivicion = False
End If
End Sub

Private Sub Command16_Click()
Text1 = 0
suma = 0
resta = 0
multi = 0
divicion = 0
End Sub



Private Sub Command2_Click()
Text1 = Text1 + Str(2)
End Sub
Private Sub Command3_Click()
Text1 = Text1 + Str(3)
End Sub
Private Sub Command4_Click()
Text1 = Text1 + Str(4)
End Sub
Private Sub Command5_Click()
Text1 = Text1 + Str(5)End Sub
Private Sub Command6_Click()
Text1 = Text1 + Str(6)
End Sub
Private Sub Command7_Click()
Text1 = Text1 + Str(7)
End Sub
Private Sub Command8_Click()
Text1 = Text1 + Str(8)
End Sub
Private Sub Command9_Click()
Text1 = Text1 + Str(9)
End Sub
Private Sub command14_click()
divicion = Val(Text1)
Text1 = ""
bdivicion = True
End Sub

No hay comentarios:

Publicar un comentario