Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 573
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 170
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 573
Default 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
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
adding a zero in front of a colon 303mike Excel Worksheet Functions 5 June 25th 09 07:30 AM
format colon Pammy Excel Discussion (Misc queries) 2 March 24th 09 08:48 PM
how to change colon to semi-colon in CP/List Seprator Khoshravan Excel Discussion (Misc queries) 3 February 4th 09 07:41 PM
Center on colon WJason Excel Discussion (Misc queries) 3 August 20th 07 09:54 PM
Add colon to times meridklt New Users to Excel 4 May 11th 07 09:36 PM


All times are GMT +1. The time now is 07:26 PM.

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"