calculadora_basica.bas Página:1/3 D:\_TRABAJO\CLASES\CURSO_2005-06\INFORMATICA\c18\ejem\p8\ Última modificación: 31/05/2006 0:51:28 '==================================================== '// Programa ............. Calculadora básica '// Proyecto ............. Prácticas de 1ºBTO '// Autor ................ Jesús P.M. [zttsoft.com] '// Fecha ................ 30/04/2005 '// Modificación ......... 28/05/2006 '==================================================== Option Explicit Dim Men1, Men2 As Double Dim Oper As String Dim FinOper As Boolean Dim PonCero As Boolean Private Sub Autor_Click() frmAutor.Show 1 End Sub Private Sub Borrar_Click() Pantalla = 0 Oper = "" Men1 = 0 Men2 = 0 End Sub Private Sub Div_Click() Men1 = CDbl(Pantalla) Oper = "/" PonCero = True End Sub Private Sub Form_Load() Oper = "" Men1 = 0 Men2 = 0 End Sub Private Sub Igual_Click() On Error GoTo QuitarERROR Men2 = CDbl(Pantalla) Select Case Oper Case "/" Pantalla = Round(Men1 / Case "*" Pantalla = Round(Men1 * Case "-" Pantalla = Round(Men1 Case "+" Pantalla = Round(Men1 + Case "%" Pantalla = Round(Men1 * End Select Oper = "" Men1 = 0 Men2 = 0 FinOper = True Exit Sub QuitarERROR: MsgBox "OPERACIÓN NO VÁLIDA", Borrar.Value = True End Sub PSPad editor 4.5.2 (2217) www.pspad.com Men2, 2) Men2, 2) Men2, 2) Men2, 2) Men2 / 100, 2) vbCritical 31/05/2006 0:51:32 JES_0 calculadora_basica.bas Página:2/3 D:\_TRABAJO\CLASES\CURSO_2005-06\INFORMATICA\c18\ejem\p8\ Última modificación: 31/05/2006 0:51:28 Private Sub Mul_Click() Men1 = CDbl(Pantalla) Oper = "*" PonCero = True End Sub Private Sub N_Click(Index As Integer) Dim sw As Variant Select Case Index Case 10 If Pantalla = "0" Then Pantalla = "-" Else sw = "-" & Pantalla If IsNumeric(sw) Then Pantalla = "-" & Pantalla Else If Mid(sw, 1, 1) = "-" Then Pantalla = Pantalla * (-1) End If End If End If Case 11 If Pantalla = "0" Then Pantalla = "0" & "," Else sw = Pantalla + "," If IsNumeric(sw) Then Pantalla = Pantalla + "," End If End If Case Else If FinOper Or PonCero Then Pantalla = 0 FinOper = False PonCero = False End If If Pantalla = "0" Then Pantalla = Index Else Pantalla = Pantalla & Index End If End Select Beep End Sub Private Sub Por_Click() Men1 = CDbl(Pantalla) Oper = "%" PonCero = True End Sub Private Sub Pot_Click() On Error GoTo QuitarERROR Men1 = CDbl(Pantalla) Pantalla = Men1 ^ 2 Exit Sub QuitarERROR: MsgBox "OPERACIÓN NO VÁLIDA", vbCritical Borrar.Value = True PSPad editor 4.5.2 (2217) www.pspad.com 31/05/2006 0:51:32 JES_0 calculadora_basica.bas Página:3/3 D:\_TRABAJO\CLASES\CURSO_2005-06\INFORMATICA\c18\ejem\p8\ Última modificación: 31/05/2006 0:51:28 End Sub Private Sub Res_Click() Men1 = CDbl(Pantalla) Oper = "-" PonCero = True End Sub Private Sub Salir_Click() End End Sub Private Sub Sum_Click() Men1 = CDbl(Pantalla) Oper = "+" PonCero = True End Sub '/// FINAL DE CÓDIGO ///' PSPad editor 4.5.2 (2217) www.pspad.com 31/05/2006 0:51:32 JES_0