|
-
Sep 12th, 2007, 03:05 AM
#1
Thread Starter
Junior Member
VB Calculator, Decimal Places...
Hey guys, i have come across a dilemma...
i am unsure of how to get my answers to two decimal places...i can easily get it into full integer but it HAS to give all answer in 2 decimal places...
i.e. 3.123 + 3.516 = 6.64
Also if anyone can give me any pointers on the rest of my code that would be great 
Code:
Dim op As String
Option Explicit
Dim value1 As Double
Dim value2 As Double
Dim Result As Double
Dim calccount As Integer
Private Sub Command1_Click(Index As Integer)
If calccount = 0 Then
Text1.Text = " "
MsgBox ("Calculator is not on.")
End If
If calccount = 1 Then
Text1.Text = " "
calccount = calccount + 1
End If
If calccount > 1 Then
Text1.Text = Text1.Text & command1(Index).Caption
End If
End Sub
Private Sub Command10_Click()
Text1.Text = mem
End Sub
Private Sub Command3_Click()
If calccount > 0 Then
value2 = Val(Text1.Text)
Select Case (op)
Case "+"
Result = value1 + value2
Text1.Text = Result
calccount = 0
Case "-"
Result = value1 - value2
Text1.Text = Result
calccount = 0
Case "*"
Result = value1 * value2
Text1.Text = Result
calccount = 0
Case "/"
Result = value1 / value2
Text1.Text = Result
calccount = 0
End Select
End If
End Sub
Private Sub Command4_Click(Index As Integer)
Result = value1
value1 = Result + Val(Text1.Text)
Text1.Text = " "
op = Command4(Index).Caption
End Sub
Private Sub Command5_Click()
Result = 0
value1 = 0
value2 = 0
Text1.Text = "0"
calccount = 1
End Sub
Private Sub Command6_Click()
calccount = 0
Text1.Text = "0"
End Sub
Private Sub Command7_Click()
Result = 0
value1 = 0
value2 = 0
calccount = 1
Text1.Text = "0"
End Sub
Thanks,
FL.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|