Caculater with color display control
Caculater with color display control
API Declarations
Dim oper2 As Double
Dim pop As String
Dim result As Double
Dim op As String
Public act As Integer
Rate Caculater with color display control
(2(2 Vote))
Private Sub c_Click(Index As Integer)
display.Caption = 0
oper2 = 0
oper1 = 0
result = 0
op = "+"
End Sub
Private Sub c_LostFocus(Index As Integer)
display.Caption = ""
End Sub
Private Sub Command1_Click()
Unload Me
End Sub
Private Sub Command1_LostFocus()
display.Caption = ""
End Sub
Private Sub Command2_Click()
End Sub
Private Sub dig_Click(Index As Integer)
display.Caption = display.Caption + dig(Index).Caption
End Sub
Private Sub div_Click(Index As Integer)
If op = "+" Then
oper1 = Val(display.Caption) + oper2
ElseIf op = "-" Then oper1 = oper2 - Val(display.Caption)
ElseIf op = "*" Then oper1 = oper2 * Val(display.Caption)
End If
If op = "/" Then
If Val(display.Caption) = 0 Then
MsgBox "Can't Divide by Zero!!"
Else
oper1 = oper2 / Val(display.Caption)
End If
End If
If op = "" Then oper1 = Val(display.Caption)
oper2 = oper1
op = "/"
pop = op
display.Caption = oper2
End Sub
Private Sub div_LostFocus(Index As Integer)
display.Caption = ""
End Sub
Private Sub eq_Click(Index As Integer)
If op = "+" Then
result = Val(display.Caption) + oper2
End If
If op = "-" Then
result = oper2 - Val(display.Caption)
End If
If op = "/" Then
If Val(display.Caption) = 0 Then
MsgBox "Can't Divide by Zero!!"
Else
result = oper2 / Val(display.Caption)
End If
End If
If op = "*" Then
result = oper2 * Val(display.Caption)
End If
display.Caption = result
op = "+"
oper1 = 0
oper2 = 0
End Sub
Private Sub Form_Load()
display.Caption = 0
oper2 = 0
oper1 = 0
result = 0
op = "+"
End Sub
Private Sub Form_Paint()
act = 1
display.Caption = 0
Command1.SetFocus
End Sub
Private Sub HScroll1_Change()
If act = 1 Then
display.BackColor = RGB(HScroll1.Value, HScroll2.Value, HScroll3.Value)
ElseIf act = 2 Then Form1.BackColor = RGB(HScroll1.Value, HScroll2.Value, HScroll3.Value)
ElseIf act = 3 Then display.ForeColor = RGB(HScroll1.Value, HScroll2.Value, HScroll3.Value)
End If
End Sub
Private Sub HScroll2_Change()
If act = 1 Then
display.BackColor = RGB(HScroll1.Value, HScroll2.Value, HScroll3.Value)
ElseIf act = 2 Then Form1.BackColor = RGB(HScroll1.Value, HScroll2.Value, HScroll3.Value)
ElseIf act = 3 Then display.ForeColor = RGB(HScroll1.Value, HScroll2.Value, HScroll3.Value)
End If
End Sub
Private Sub HScroll3_Change()
If act = 1 Then
display.BackColor = RGB(HScroll1.Value, HScroll2.Value, HScroll3.Value)
ElseIf act = 2 Then Form1.BackColor = RGB(HScroll1.Value, HScroll2.Value, HScroll3.Value)
ElseIf act = 3 Then display.ForeColor = RGB(HScroll1.Value, HScroll2.Value, HScroll3.Value)
End If
End Sub
Private Sub minus_Click(Index As Integer)
If op = "+" Then
oper1 = Val(display.Caption) + oper2
ElseIf op = "-" Then oper1 = oper2 - Val(display.Caption)
ElseIf op = "*" Then oper1 = oper2 * Val(display.Caption)
End If
If op = "/" Then
If Val(display.Caption) = 0 Then
MsgBox "Can't Divide by Zero!!"
Else
oper1 = oper2 / Val(display.Caption)
End If
End If
If op = "" Then oper1 = oper2 - Val(display.Caption)
oper2 = oper1
op = "-"
pop = op
display.Caption = oper2
End Sub
Private Sub minus_LostFocus(Index As Integer)
display.Caption = " "
End Sub
Private Sub mul_Click(Index As Integer)
If op = "+" Then
oper1 = Val(display.Caption) + oper2
ElseIf op = "-" Then oper1 = oper2 - Val(display.Caption)
ElseIf op = "*" Then oper1 = oper2 * Val(display.Caption)
End If
If op = "/" Then
If Val(display.Caption) = 0 Then
MsgBox "Can't Divide by Zero!!"
Else
oper1 = oper2 / Val(display.Caption)
End If
End If
If op = "" Then oper1 = oper2 * Val(display.Caption)
oper2 = oper1
op = "*"
pop = op
display.Caption = oper2
End Sub
Private Sub mul_LostFocus(Index As Integer)
display.Caption = ""
End Sub
Private Sub Option1_Click()
act = 1
End Sub
Private Sub Option2_Click()
act = 2
End Sub
Private Sub Option3_Click()
act = 3
End Sub
Private Sub per_Click()
If oper1 <> 0 And Val(display.Caption) <> 0 Then
oper1 = Val(display.Caption) * oper1 / 100
display.Caption = oper1
Else
display.Caption = 0
End If
End Sub
Private Sub plus_Click(Index As Integer)
If op = "+" Then
oper1 = Val(display.Caption) + oper2
ElseIf op = "-" Then oper1 = oper2 - Val(display.Caption)
ElseIf op = "*" Then oper1 = oper2 * Val(display.Caption)
End If
If op = "/" Then
If Val(display.Caption) = 0 Then
MsgBox "Can't Divide by Zero!!"
Else
oper1 = oper2 / Val(display.Caption)
End If
End If
If op = "" Then oper1 = Val(display.Caption) + oper2
oper2 = oper1
op = "+"
pop = op
display.Caption = oper2
End Sub
Private Sub plus_LostFocus(Index As Integer)
display.Caption = " "
End Sub
Private Sub sqrt_Click()
display.Caption = Sqr(display.Caption)
End Sub
Private Sub upon_Click(Index As Integer)
display.Caption = 1 / Val(display.Caption)
End Sub
Private Sub upon_LostFocus(Index As Integer)
'display.Caption = ""
End Sub
Caculater with color display control Comments
No comments yet — be the first to post one!
Post a Comment