I have a really simple Question: Is there another option to +=
or -=
in VBA
?
like:
a += b
instead of:
a = a + b
Thank you very much in advance for your answers...
I have a really simple Question: Is there another option to +=
or -=
in VBA
?
like:
a += b
instead of:
a = a + b
Thank you very much in advance for your answers...
The compound assignment operators (e.g. +=
, -=
) do not exist in VBA (which has a similar grammar to VB6, the precursor to VB.net).
You need to fall back to the equivalent a = a + b
.
Not that I'm aware of. This is MDSN link which shows VBA operators and expressions
Try something like this:
Public Sub Increment(ByRef value_to_increment, Optional l_plus As Long = 1)
value_to_increment = value_to_increment + l_plus
End Sub
Public Sub Decrement(ByRef value_to_decrement, Optional l_minus As Long = 1)
value_to_decrement = value_to_decrement - l_minus
End Sub
This is something that I am using daily. It somehow makes it easier for me. Usage is like this:
Call Increment(lValue)
Example of usage here.