Calculadora Sencilla

Descargar como docx, pdf o txt
Descargar como docx, pdf o txt
Está en la página 1de 5

Visual Basic 6.

0 Calculadora
[1] 3 A B L.I. JOSE GUADALUPE GONZALEZ PEREYRA


'Calculadora sencilla
'Desarrollado por L.I. Jos Guadalupe Gonzlez Pereyra
'Correo: profe.compu.287@gmail.com
Option Explicit
Dim strPreviousValue As String
Dim strOperator As String
Dim blnDot As Boolean
Dim strMemory As String
Dim blnDisplay As Boolean
Dim strAuthor As String

Private Sub Command1_Click()
If Len(lblDisplay) > 0 Then
lblDisplay = Mid$(lblDisplay, 1, Len(lblDisplay) - 1)
Else
Beep
End If
End Sub

Visual Basic 6.0 Calculadora
[2] 3 A B L.I. JOSE GUADALUPE GONZALEZ PEREYRA
Private Sub Form_Load()
lblDisplay.Caption = "0"
strPreviousValue = ""
strMemory = "0"
strOperator = ""
blnDot = False
blnDisplay = True
strAuthor = "Author:Jos Guadalupe Glez. Pereyra (Esc. Sec. Oficial No.
0287 ," + "Fray Andrs de Castro) Email:profe.compu.287@gmail.com
Fecha de Creacin:Mayo. 22, 2014 -- "
End Sub


Private Sub cmdNumber_Click(Index As Integer)
If blnDisplay = True Then
If blnDot = False And lblDisplay.Caption = "0" Then
lblDisplay.Caption = ""
End If
lblDisplay.Caption = lblDisplay.Caption + cmdNumber(Index).Caption
Else
strPreviousValue = lblDisplay.Caption
lblDisplay.Caption = cmdNumber(Index).Caption
blnDisplay = True
End If
End Sub


Private Sub cmdDot_Click()
If blnDisplay = True Then
If blnDot = False Then
blnDot = True
lblDisplay.Caption = lblDisplay.Caption + "."
End If
Exit Sub
End If
If blnDisplay = False And blnDot = False Then
lblDisplay.Caption = "0."
Visual Basic 6.0 Calculadora
[3] 3 A B L.I. JOSE GUADALUPE GONZALEZ PEREYRA
blnDisplay = True
blnDot = True
End If
End Sub


Private Sub cmdCE_Click()
If Timer1.Enabled = True Then Timer1.Enabled = False
blnDot = False
lblDisplay.Caption = "0"
strOperator = ""
strPreviousValue = "0"
End Sub


Private Sub cmdOperator_Click(Index As Integer)
blnDot = False
blnDisplay = False
If Len(strOperator) = 1 Then
Call math
strOperator = cmdOperator(Index).Caption
Else
strOperator = cmdOperator(Index).Caption
strPreviousValue = lblDisplay.Caption
End If
End Sub


Private Function math()
On Error GoTo errorHandler
Select Case strOperator
Case "+"
lblDisplay.Caption = Val(lblDisplay.Caption) + Val(strPreviousValue)
Case "-"
lblDisplay.Caption = Val(strPreviousValue) - Val(lblDisplay.Caption)
Case "x"
lblDisplay.Caption = Val(lblDisplay.Caption) * Val(strPreviousValue)
Visual Basic 6.0 Calculadora
[4] 3 A B L.I. JOSE GUADALUPE GONZALEZ PEREYRA
Case "/"
lblDisplay.Caption = Val(strPreviousValue) / Val(lblDisplay.Caption)
End Select
Exit Function
errorHandler:
lblDisplay.Caption = "Error "
strOperator = ""
strPreviousValue = "0"
blnDot = False
blnDisplay = False
End Function


Private Sub cmdIsEqualTo_Click()
Call math
strOperator = ""
If Len(lblDisplay.Caption) <= 19 Then
lblDisplay.FontSize = 15
Else
lblDisplay.FontSize = 10
End If
End Sub


Private Sub cmdPlusOrMinus_Click()
lblDisplay.Caption = Val(lblDisplay.Caption) - (Val(lblDisplay.Caption) +
Val(lblDisplay.Caption))
End Sub
Private Sub cmdSqrt_Click()
lblDisplay.Caption = Sqr(Val(lblDisplay.Caption))
End Sub






Visual Basic 6.0 Calculadora
[5] 3 A B L.I. JOSE GUADALUPE GONZALEZ PEREYRA
Private Sub cmdMemory_Click(Index As Integer)
If Timer1.Enabled = False Then
Select Case cmdMemory(Index).Caption
Case "M+"
strMemory = Val(strMemory) + Val(lblDisplay.Caption)
Case "M-"
strMemory = Val(strMemory) - Val(lblDisplay.Caption)
Case "MR"
lblDisplay.Caption = strMemory
blnDisplay = False
Case "MC"
strMemory = "0"
lblDisplay.Caption = "0"
End Select
End If
End Sub



Private Sub Timer1_Timer()
strAuthor = Mid$(strAuthor, 2, Len(strAuthor) - 1) + Left(strAuthor, 1)
lblDisplay.Caption = Left(strAuthor, 18)
Form1.Width = 4095
Form1.Height = 3960
End Sub

También podría gustarte