VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Caculater with color display control

by Nadeem Gulzar Rana (3 Submissions)
Category: Math/Dates
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Sat 30th September 2000
Date Added: Mon 8th February 2021
Rating: (1 Votes)

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



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


Download this snippet    Add to My Saved Code

Caculater with color display control Comments

No comments have been posted about Caculater with color display control. Why not be the first to post a comment about Caculater with color display control.

Post your comment

Subject:
Message:
0/1000 characters