Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 13
Default increment operator?

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.


  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,290
Default increment operator?

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.


  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 947
Default increment operator?

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

--
HTH :)
Dana DeLouis
Windows XP & Office 2003


"Peter Morris" <nospam.ple@se wrote in message
. uk...
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.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
'Scroll bar' - to increment btwn MIN and MAX value. jay Charts and Charting in Excel 1 April 28th 06 02:15 AM
check cell val, increment val DJS Excel Worksheet Functions 0 January 30th 06 10:29 PM
need to increment value Tom Excel Discussion (Misc queries) 5 June 24th 05 12:54 PM
Relative reference autofill increment other than +1 SteveB Excel Discussion (Misc queries) 3 June 14th 05 07:40 PM
"OR" operator to evaluate multiple conditions anand Excel Worksheet Functions 1 May 23rd 05 08:49 PM


All times are GMT +1. The time now is 12:25 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"