vba increments shortcuts (like C++?)

T

tonyrulesyall

I was wondering if there was a programming shortcut for increments
in access vba?

ex: instead of:
intcounter = intcounter + 1

something like
intcounter ++
 
C

Clif McIrvin

Douglas J. Steele said:
No. You must use intcounter = intcounter + 1

But you can do something like:

(air code)

intcounter = AutoIncrement(intcounter)


Function AutoIncrement (Num as Long, Optional Step as Long = 1) as Long
AutoIncrement = Num + Step
End Function
 
G

Guest

But why bother?

++ is important in C because it is an overloaded operator: it
increments pointer values by SizeOf(referenced value).

Pointer values are important in C because the language doesn't
support ByRef parameters.

But VBA has support for referenced variables built into the
language, so referenced variable support doesn't need to be
created ad-hoc by the programmer, so VBA doesn't need an
overloaded ++ operator, so it doesn't need a ++ operator at
all.

The only remaining reason for a ++ operator would be for
people who can't type, and the suggested solution doesn't
cater for them either:
intcounter = AutoIncrement(intcounter)

(david)
 
Top