Alpha Video Training
Results 1 to 5 of 5

Thread: Calculation Help

  1. #1
    "Certified" Alphaholic
    Real Name
    John Koh
    Join Date
    Jan 2004
    Location
    Maryland, USA
    Posts
    1,077

    Default Calculation Help

    Hi All,

    Simple calculation and have trouble when it is negative number

    I have this and
    1. Is there better way to calculate the Balance?
    2. Do I have to change negative to positive number?



    Code:
    'add number
    a = 542
    b = -211		'negative number
    c = 186
    d = 374
    
    x = a+b+c+d		'Get total -- ok
    
    
    'get the balance
    'balance = a - b		'It is wrong result when the number is negative. Unknown negative number or not
    
    
    if b < 0 then
    	'msgbox("b is less than 0 and ...") 
    	'How to change to positive number?
    	balance = a + b		'Unknown negative number or not
    else
    	balance = a - b		'Unknown negative number or not
    end if
    ui_msg_box("result","balance "+balance)

  2. #2
    Volunteer Moderator
    Real Name
    Alan Buchholz
    Join Date
    Oct 2000
    Location
    Delavan, Wisconsin
    Posts
    9,618

    Default Re: Calculation Help

    if a,b,c,d are transactions, what is the beginning balance?

    Zero?

    Need more info.

    What do you expect the balance to be?
    Al Buchholz
    Bookwood Systems, LTD
    Weekly QReportBuilder Webinars Thursday 1 pm CST

    Occam's Razor - KISS
    Normalize till it hurts - De-normalize till it works.
    Advice offered and questions asked in the spirit of learning how to fish is better than someone giving you a fish.
    When we triage a problem it is much easier to read sample systems than to read a mind.

  3. #3
    "Certified" Alphaholic
    Real Name
    John Koh
    Join Date
    Jan 2004
    Location
    Maryland, USA
    Posts
    1,077

    Default Re: Calculation Help

    Hi Al,

    It is general subtract calculation, not typical "Balance" calculation.

    what is the beginning balance? -- "A" Value
    What do you expect the balance to be? --> a(*542) - b(*211) = 331.00

    I want to write a code as xBal = a - b but when the "B" is negative number then trouble.

    Thank you

  4. #4
    Volunteer Moderator
    Real Name
    Alan Buchholz
    Join Date
    Oct 2000
    Location
    Delavan, Wisconsin
    Posts
    9,618

    Default Re: Calculation Help

    Quote Originally Posted by johnkoh View Post
    Hi Al,

    It is general subtract calculation, not typical "Balance" calculation.

    what is the beginning balance? -- "A" Value
    What do you expect the balance to be? --> a(*542) - b(*211) = 331.00

    I want to write a code as xBal = a - b but when the "B" is negative number then trouble.

    Thank you
    a-abs(b)
    Al Buchholz
    Bookwood Systems, LTD
    Weekly QReportBuilder Webinars Thursday 1 pm CST

    Occam's Razor - KISS
    Normalize till it hurts - De-normalize till it works.
    Advice offered and questions asked in the spirit of learning how to fish is better than someone giving you a fish.
    When we triage a problem it is much easier to read sample systems than to read a mind.

  5. #5
    "Certified" Alphaholic
    Real Name
    John Koh
    Join Date
    Jan 2004
    Location
    Maryland, USA
    Posts
    1,077

    Default Re: Calculation Help

    Thanks, Al

Similar Threads

  1. Age Calculation
    By Karaiskakis in forum Application Server Version 10 - Web/Browser Applications
    Replies: 6
    Last Post: 03-14-2011, 10:45 PM
  2. Calculation Help
    By Tom Henkel in forum Alpha Five Version 10 - Desktop Applications
    Replies: 9
    Last Post: 03-01-2011, 01:14 PM
  3. Age Calculation
    By mgorom in forum Alpha Five Version 5
    Replies: 4
    Last Post: 10-01-2004, 07:01 AM
  4. Calculation BUG!!!
    By Fred Daniel in forum Alpha Five Version 5
    Replies: 9
    Last Post: 06-07-2003, 11:49 AM
  5. Need help with calculation
    By Wanda Friesen in forum Alpha Five Version 4
    Replies: 2
    Last Post: 08-16-2000, 09:26 AM

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
  •