Results 1 to 5 of 5

Thread: Simple Mathematical Operation - Need Help From Expert

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2007
    Posts
    3

    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.

  2. #2
    Member cleverconcepts's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    44

    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.
    bleh

  3. #3
    PowerPoster Code Doc's Avatar
    Join Date
    Mar 2007
    Location
    Omaha, Nebraska
    Posts
    2,354

    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
    Doctor Ed

  4. #4

    Thread Starter
    New Member
    Join Date
    Jan 2007
    Posts
    3

    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.

  5. #5

    Thread Starter
    New Member
    Join Date
    Jan 2007
    Posts
    3

    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
  •  



Click Here to Expand Forum to Full Width