|
-
Mar 16th, 2007, 01:16 AM
#1
Thread Starter
New Member
Simple Mathematical Operation - Need Help From Expert
Hi!
I'm new in this forum. Just wanna ask. How to solve this equation:
I have 3 value (A=13, B=3 and C=4.3333)
The eqution is: 13 / 3 = 4.3333
But when 4.3333 * 3 = 12.9999. How I'm suppose to tell the computer that 12.9999 is equal to A? My problem is more complex than this example. This just an example to simplify my problem situation. Did anybody has an explanation to solve this problem? Thank You in advance for you.
-
Mar 16th, 2007, 03:17 AM
#2
Member
Re: Simple Mathematical Operation - Need Help From Expert
try using the currency data type
dim c1 as currency etc
the problem is that the computer cannot display all fractions properly and so suffers from rouding point errors. the easy answer is to use either currency or decimal datatypes in all situations where fractions are required.
-
Mar 20th, 2007, 01:20 PM
#3
Re: Simple Mathematical Operation - Need Help From Expert
Let C be defined by A / B , which are both whole numbers, rather that read it in as data. Then C * B will always = A and say good bye to 12.99999999999 etc.
Code:
Dim A As Single, B As Single, C As Single
Private Sub Form_Load()
A = 13
B = 3
C = A / B
Label1.Caption = Str(C * B) 'Displays 13
End Sub
-
Mar 21st, 2007, 09:20 AM
#4
Thread Starter
New Member
Re: Simple Mathematical Operation - Need Help From Expert
Hi there cleverconcepts and Doctor Ed!
Thanks for your help... I really appreciate it. I'll try your suggestions. I'll give the response back for the knowledge to our forum. Thanks pal.
-
Mar 30th, 2007, 01:49 AM
#5
Thread Starter
New Member
Re: Simple Mathematical Operation - Need Help From Expert
OMG.. Thanks guys! Both works! ;-)
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
|