vba increments shortcuts (like C++?)

  • Thread starter Thread starter tonyrulesyall
  • Start date Start date
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 ++
 
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
 
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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top