Results 1 to 4 of 4
  1. #1
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Melbourne, Australia
    Posts
    1,294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    can you multiply/divide in VBA (w97 sr2b)

    for working out totals I've only had to use add (+) or subtract (-).
    I've never had to multiply or divide.

    I'm in a situation where I would like to multiply a number by a number. I've used the following syntax....
    lngChequeTotal = (lngClassAmount x j)

    however I've already defined x as a long & used it to store a numeric value, therefore the above is not going to work.

    How can I multiply in VBA? is it a function?
    if it cant be done then I'll just use a For statement & add the amount?

    many thanks Diana

  2. #2
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Weert, Limburg, Netherlands
    Posts
    4,812
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: can you multiply/divide in VBA (w97 sr2b)

    From Excel VBA Help:

    When several operations occur in an expression, each part is evaluated and resolved in a predetermined order called operator precedence.

    When expressions contain operators from more than one category, arithmetic operators are evaluated first, comparison operators are evaluated next, and logical operators are evaluated last. Comparison operators all have equal precedence; that is, they are evaluated in the left-to-right order in which they appear. Arithmetic and logical operators are evaluated in the following order of precedence:

    <table border=1><td align=center>Arithmetic</td><td align=center>Comparison</td><td align=center>Logical</td><td valign=top>Exponentiation (^)</td><td valign=top>Equality (=)</td><td valign=top>Not</td><tr><td valign=top>Negation (
    Jan Karel Pieterse
    Microsoft Excel MVP, WMVP
    www.jkp-ads.com
    Professional Office Developers Association

  3. #3
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: can you multiply/divide in VBA (w97 sr2b)

    For future reference in learning programming languages, these are almost always called operators and should have their own section (or more than one, when arithmetic and string operators are treated separately) in the manual or online help. You'd be amazed at some of the variations...

  4. #4
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Melbourne, Australia
    Posts
    1,294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: can you multiply/divide in VBA (w97 sr2b)

    many thanks for your help
    Diana

Posting Permissions

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