Home |
Search |
Today's Posts |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
i+=1 instead of i=i+1
Just to mention if you like it. When we just want to increase a variable by 1, we most likely would use the PreIncrement function "++" (ie ++ v) In vba, it's generally not recommended, but we can have fun with function names in a few cases. I also have the Inc function, but whose name is ++, or the characters Alt + 0134 (twice) Hold down the Alt key and type 0134. Function ††(ByRef n) ' Alt + 0134 n = n + 1 End Function Sub Demo() Dim n n = 5 †† n End Sub 'n is now 6. You have to use a little imagination to find characters that are close to what you need. In addition, not all characters are valid. HTH Dana DeLouis Dana DeLouis wrote: Does anyone know if there is a VBA-equivalent of the "+=" operator in C. i+=1 instead of i=i+1 Here' a workaround that I use for the Increment function. I also have a "Decrement" function as well. Function Inc(ByRef n) '// Increment by +1 n = n + 1 End Function Sub Demo() Dim AVeryLongVariableName AVeryLongVariableName = 5 AVeryLongVariableName = AVeryLongVariableName + 1 'or Inc AVeryLongVariableName End Sub HTH Dana DeLouis Charles wrote: That basically answers my question. I must say I have never been a great fan of C/C++ (too rigorous for me) but I regret a few functions like that one... thanks! Charles |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Text "comparison" operator for "contains" used in an "IF" Function | Excel Worksheet Functions | |||
Is it possible to apply IF's to "operator" result.. | Excel Discussion (Misc queries) | |||
program stuck at "Save Cancelled by Operator" | Excel Discussion (Misc queries) | |||
How 2 use right shift "<<" and left shift "" operator in excel? | Excel Programming | |||
Excel no longer allows new formulas with division "/" operator | Excel Programming |