Variable doesn't store decimal value correctly (1 Viewer)

aman

Registered User.
Local time
Yesterday, 18:57
Joined
Oct 16, 2008
Messages
1,250
Hi guys

I am getting a problem in storing correct decimal value in a textbox. E.g text12=7.30 and text83=6.10 then in the following code text130 stores value 1.2 which is not correct. The right value should be 1.20

Code:
Text130 = Val(Text12) - Val(Text83)
MsgBox "Please select any suitable option from the option box in the form to put rest of " & Text130 & " hrs", vbInformation, "Select an option"

Can anyone please sort out my problem.

Thanks
Aman
 

DCrake

Remembered
Local time
Today, 02:57
Joined
Jun 8, 2005
Messages
8,632
Text130 = Format(Val(Text12) - Val(Text83),"#0.00")

Also try to give you field names a meaningful name, anyone trying to decypher your code would be pulling their hair out.

BTW 1.2 is the same as 1.20 if you have not set the properties correctly then Access will remove any trailing zeros.

Format:Fixed
Decimal Places:2

David
 

aman

Registered User.
Local time
Yesterday, 18:57
Joined
Oct 16, 2008
Messages
1,250
Thanks a lot Dcrake.

It worked perfectly.
 

Users who are viewing this thread

Top Bottom