Reputation: 1
I have a form where user inputs the Sales Price and vba calculates the commission based on a fixed percentage and then calculates advertisement fees (again a percentage). The advertisement fees is deducted from the commission to arrive at the net commission. I have written the following code:
Dim sales, comm, conj As Long
comm = 0
conj = 0
sales = 0
sales = [Forms]![Frmaddnewsales]![txtsales]
comm = sales * .019
conj = comm * .09
Exit Sub
As an example, I enter sales price as $650000028, it calculates commission=12350000.532 and then conj=1111500. I need both the comm and conj variable to store only rounded values(without decimals). My question is since my variables are declared as Long why is it storing decimals. Why is comm showing in decimal whereas and conj variable is only showing the rounded figure.
Upvotes: 0
Views: 50
Reputation: 93181
Welcome to one of the syntactic quirks of VB. This line:
Dim sales, comm, conj As Long
Means only conj
is Long
. The first two are of type Variant
. You can try this:
Dim sales as Long, comm as Long, conj as Long
Upvotes: 3