+ Reply to Thread
Results 1 to 9 of 9

Calculate using decimals?

  1. #1
    Forum Contributor onmyway's Avatar
    Join Date
    09-03-2012
    Location
    Johannesburg, South Africa
    MS-Off Ver
    2013
    Posts
    386

    Calculate using decimals?

    Hi guys,

    I hope you can help with solving this Format and calculation issue.

    All my fields in my calculation are formatted to make use of the following format: 1,00. I.e, it automatically takes a single decimal, and add the (,) comma ad 2 zeros. One can also capture a number with decimal, like 1,25

    The problem is that my answer/result field .txtStockEOS1 does not calculate the decimals, only the numbers before the (,). Note: This field has not been formatted. I.e., 10 = 5,8 + 3,8 + 2,5, instead of the answer being 12,1

    Here is my code that calculates on Change event:

    Please Login or Register  to view this content.
    Thank you all!
    Last edited by onmyway; 03-12-2015 at 11:10 AM.
    Sharing knowledge, can be likened to taking another person's hand, and pulling them up to a higher level -- onmyway

    If I was helpful, please remember to click on * Add Reputation below

  2. #2
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP, 2007, 2024
    Posts
    16,436

    Re: Calculate using decimals?

    I'm not sure why it would, but it suggests that it is treating each addend as an integer rather than a double. One would probably need to see this in the larger context, but the first thing I would check would be the data types of the variables and make sure they are double and not integer or long.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  3. #3
    Forum Contributor onmyway's Avatar
    Join Date
    09-03-2012
    Location
    Johannesburg, South Africa
    MS-Off Ver
    2013
    Posts
    386

    Re: Calculate using decimals?

    Hi MrShorty,

    There are no declared variables.

    I simply have textBoxes that triggers the calculation each time a change occurs in one of the text boxes.

    Unless you are perhaps refering to this code used for formatting my textBoxes:

    Please Login or Register  to view this content.
    Is there a way I can declare each of these fields as a Double?

    Something like:

    Please Login or Register  to view this content.
    Thank you!

  4. #4
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: Calculate using decimals?

    Store the Textbox values in variable and run the code in break mode and see the locals window about how the textbox values storing in variables


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  5. #5
    Forum Contributor onmyway's Avatar
    Join Date
    09-03-2012
    Location
    Johannesburg, South Africa
    MS-Off Ver
    2013
    Posts
    386

    Re: Calculate using decimals?

    Ah!

    Something like:

    Please Login or Register  to view this content.
    Would I put that in my Private Sub txtStockSOS1_Exit event?

  6. #6
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: Calculate using decimals?

    Attach a sample workbook. Make sure there is just enough data to make it clear what is needed. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are demonstrated, mock them up manually if needed. Remember to desensitize the data.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic

  7. #7
    Forum Contributor onmyway's Avatar
    Join Date
    09-03-2012
    Location
    Johannesburg, South Africa
    MS-Off Ver
    2013
    Posts
    386

    Re: Calculate using decimals?

    Hi Sixthsense,

    Thanks for your help. I have done the following, and it seems to work. Perhaps you can give me your thoughts?

    I Public declared the following:

    Please Login or Register  to view this content.
    I then included my _Change() event in my _Exit event, thus combining my calculation and field formatting:

    Please Login or Register  to view this content.
    This calculates my value with every field exit, and it does update my answer/value field with a Double value - number and decimal.

    One question:

    I have tried adding the following line of code beneath my calculation (where I put the * above):

    Please Login or Register  to view this content.
    But it changes the value from 2,5 to 0,13 for instance?

  8. #8
    Forum Contributor onmyway's Avatar
    Join Date
    09-03-2012
    Location
    Johannesburg, South Africa
    MS-Off Ver
    2013
    Posts
    386

    Re: Calculate using decimals?

    So, in other words; how can I declare or format my answer field as Numeric, with the following format #,##0.00 ?

  9. #9
    Forum Contributor onmyway's Avatar
    Join Date
    09-03-2012
    Location
    Johannesburg, South Africa
    MS-Off Ver
    2013
    Posts
    386

    Re: Calculate using decimals?

    Hi all,

    i got it working. Here is my code:

    Please Login or Register  to view this content.
    Please feel free to give me your input regarding my method, and possible better solutions and methods.

    Be blessed!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] How do I calculate without decimals in excel?
    By upstate in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 06:05 PM
  2. [SOLVED] How do I calculate without decimals in excel?
    By upstate in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 03:05 PM
  3. How do I calculate without decimals in excel?
    By Duke Carey in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-06-2005, 04:05 AM
  4. How do I calculate without decimals in excel?
    By upstate in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 03:05 AM
  5. How do I calculate without decimals in excel?
    By upstate in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-05-2005, 11:05 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1