AnyThing That Rockz
Home­FAQ­Search­Memberlist­Usergroups­Register­Log in
Post new topic   Reply to topicShare | 
 

 Simple Calculator

View previous topic View next topic Go down 
AuthorMessage
QuartzZapphyre
Admin


Posts: 29
Join date: 2008-08-15
Age: 19

PostSubject: Simple Calculator   Tue Mar 17, 2009 11:27 am

Option Explicit
Dim x As Integer
Dim num1 As Double
Dim num2 As Double
Dim operation As String

Private Sub cmd0_Click()
txtNumber.Text = txtNumber & "0"
End Sub

Private Sub cmd1_Click()
txtNumber.Text = txtNumber & "1"
End Sub

Private Sub cmd2_Click()
txtNumber.Text = txtNumber & "2"
End Sub

Private Sub cmd3_Click()
txtNumber.Text = txtNumber & "3"
End Sub

Private Sub cmd4_Click()
txtNumber.Text = txtNumber & "4"
End Sub

Private Sub cmd5_Click()
txtNumber.Text = txtNumber & "5"
End Sub

Private Sub cmd6_Click()
txtNumber.Text = txtNumber & "6"
End Sub

Private Sub cmd7_Click()
txtNumber.Text = txtNumber & "7"
End Sub

Private Sub cmd8_Click()
txtNumber.Text = txtNumber & "8"
End Sub

Private Sub cmd9_Click()
txtNumber.Text = txtNumber & "9"
End Sub

Private Sub cmdDivide_Click()
num1 = txtNumber
txtNumber.Text = ""
operation = "/"
End Sub

Private Sub cmdEqual_Click()
If operation = "+" Then
txtNumber.Text = num1 + txtNumber
ElseIf operation = "-" Then
txtNumber.Text = num1 - txtNumber
ElseIf operation = "*" Then
txtNumber.Text = num1 * txtNumber
ElseIf operation = "/" Then
txtNumber.Text = num1 / txtNumber
End If
End Sub

Private Sub cmdMinus_Click()
num1 = txtNumber
txtNumber.Text = ""
operation = "-"
End Sub

Private Sub cmdMultiply_Click()
num1 = txtNumber
txtNumber.Text = ""
operation = "*"
End Sub

Private Sub cmdPeriod_Click()
If x >= 1 Then
cmdPeriod.Enabled = False
Else
txtNumber.Text = txtNumber & "."
End If
x = 1
End Sub

Private Sub cmdPlus_Click()
num1 = txtNumber
txtNumber.Text = ""
operation = "+"
End Sub

Private Sub txtNumber_KeyPress(KeyAscii As Integer)
If KeyAscii >= 48 And KeyAscii <= 57 Then
'Then the data the user has inputed is a number
Else
KeyAscii = 0
'Then the data the user has inputed is not a number
End If
End Sub

=============================================================================


lol! lol! lol! lol!
Back to top Go down
View user profile http://bugsoff.forumotion.net
 

Simple Calculator

View previous topic View next topic Back to top 
Page 1 of 1

Permissions of this forum:You cannot reply to topics in this forum
BUGSoFF :: BUGS :: The Easy Way Out-
Post new topic   Reply to topic