increment operator?

  • Thread starter Thread starter Peter Morris
  • Start date Start date
P

Peter Morris

Is there a shorthand increment operator ?

eg something like :
Inc(long.variable.name)

which would be easier to read than
long.variable.name = long.variable.name + 1



Also decrement too.
 
You could create one...
lngNum = AddOne(lngNum)

Function AddOne(ByVal lngN As Long) As Long
AddOne = lngN + 1
End Function

-or-

Call AddOne(lngNum)

Function AddOne(ByRef lngN As Long)
lngN = lngN + 1
End Function
-----------
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware



"Peter Morris"
<nospam.ple@se>
wrote in message
Is there a shorthand increment operator ?
eg something like :
Inc(long.variable.name)

which would be easier to read than
long.variable.name = long.variable.name + 1
Also decrement too.
 
eg something like :
Inc(long.variable.name)

Excel vba doesn't have the ++n operator as in some other programs.
Another option similar to Jim's but without parenthesis might be:

Function Inc(ByRef n)
'// Increment by +1
n = n + 1
End Function

Sub Example()
Dim long_variable_name
long_variable_name = 10

Inc long_variable_name
End Sub
 

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