Display Decimal

BJS

Registered User.
Local time
Today, 13:34
Joined
Aug 29, 2002
Messages
109
Hi,

I am creating a basic calcualtor within my Access application.

I'm having trouble assigning the value "0." to num1

When the caluclator loads, num1 = 0, and num2 = 0. When clicking on the "decimal" button, I would like the value of "lblResult" label to display "0." and num1 should equal "0."

My code:

Dim num1 as double
Dim num2 as double
num1 = 0
num2 = 0

If num1 = 0 And prevOperator = "" Then
lblResult.Text = CStr(0 & ".")
num1 = lblResult.Text
End If

My problem seems to be assigning a string to a double. How do I get around this? I need the program to remember that num1 now contains a decimal, so that when the user clicks on the number 1 next, the result will display "0.1"

I'd appreciate any help with this.
BJ
 
My problem seems to be assigning a string to a double.
Well, that's because you can't. This line:
num1 = lblResult.Text
will not work the way you want it to.

If lblResult is a textbox, try:
Me.num1 = Cdbl(Me.lblResult)
 

Users who are viewing this thread

Back
Top Bottom