Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Colon in code?
What does a colon in VBA code do? I.e.,
Hide: I tried to figure out how to look this up both online and in Walkenbach, but couldn't find anything on it. Thanks. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Colon in code?
It separates two logical lines of code into a single line of
text. E.g., the following code snippets are functionally equivalent: Dim X As Long: X = 123 Dim X As Long X = 123 "davegb" wrote in message oups.com... What does a colon in VBA code do? I.e., Hide: I tried to figure out how to look this up both online and in Walkenbach, but couldn't find anything on it. Thanks. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Colon in code?
I should have added that the colon is also used to label a
location in code, typically used for On Error Goto Label statements. On Error GoTo ErrH: ' some code ErrH: ' error code here -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "davegb" wrote in message oups.com... What does a colon in VBA code do? I.e., Hide: I tried to figure out how to look this up both online and in Walkenbach, but couldn't find anything on it. Thanks. |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Colon in code?
In this case, I suspect "Hide:" is a line label (Colons can also be used to
separate multi commands on a single line, but that doesn't seem to be the case here). There is probably a "GoTo Hide" instruction somewhere in the same function/procedure where you found it (if there isn't, there probably was one at some point in time and someone simply forgot to take the corresponding label out.) Use of line labels and goto's is (generally) frowned upon (outside of Error trapping where they are a necessity). This has become one of those "rules to be broken" because improper/overuse of them is an very easy trap for newbie coders to fall into since there is (almost) always a better way to achieve the same results. Extreme caution is advised or you could quickly end up with "spaghetti code" that jumps all over the place: something totally unreadable & unmanageable, even if you wrote it yourself yesterday. "Line labels" doesn't warrant an entry in Help, but you can get to a hyperlink definition of them via the entry for the "GoTo" statement. Let's be careful out there... HTH, -- George Nicholson Remove 'Junk' from return address. "davegb" wrote in message oups.com... What does a colon in VBA code do? I.e., Hide: I tried to figure out how to look this up both online and in Walkenbach, but couldn't find anything on it. Thanks. |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Colon in code?
George Nicholson wrote: In this case, I suspect "Hide:" is a line label (Colons can also be used to separate multi commands on a single line, but that doesn't seem to be the case here). There is probably a "GoTo Hide" instruction somewhere in the same function/procedure where you found it (if there isn't, there probably was one at some point in time and someone simply forgot to take the corresponding label out.) Use of line labels and goto's is (generally) frowned upon (outside of Error trapping where they are a necessity). This has become one of those "rules to be broken" because improper/overuse of them is an very easy trap for newbie coders to fall into since there is (almost) always a better way to achieve the same results. Extreme caution is advised or you could quickly end up with "spaghetti code" that jumps all over the place: something totally unreadable & unmanageable, even if you wrote it yourself yesterday. "Line labels" doesn't warrant an entry in Help, but you can get to a hyperlink definition of them via the entry for the "GoTo" statement. Let's be careful out there... HTH, -- George Nicholson Remove 'Junk' from return address. "davegb" wrote in message oups.com... What does a colon in VBA code do? I.e., Hide: I tried to figure out how to look this up both online and in Walkenbach, but couldn't find anything on it. Thanks. Thanks for all your replys! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
adding a zero in front of a colon | Excel Worksheet Functions | |||
format colon | Excel Discussion (Misc queries) | |||
how to change colon to semi-colon in CP/List Seprator | Excel Discussion (Misc queries) | |||
Center on colon | Excel Discussion (Misc queries) | |||
Add colon to times | New Users to Excel |