473,756 Members | 8,108 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using a colon ":" to Seperate Statements

Is it acceptable to use a colon ":" to seperate statements in VBA?

strVar1 = "A": lngVar2 = 0: blnVar3 = True
Msgbox strVar1: Msgbox lngVar2: Msgbox blnVar3

Thanks
Greg

Feb 16 '07 #1
4 9831
Ap******@gmail. com wrote:
>Is it acceptable to use a colon ":" to seperate statements in VBA?

strVar1 = "A": lngVar2 = 0: blnVar3 = True
Msgbox strVar1: Msgbox lngVar2: Msgbox blnVar3

It is legal syntax, but in many situations can make the code
difficult to read/debug. Use it sparingly or not at all.
--
Marsh
Feb 16 '07 #2
Ap******@gmail. com wrote:
Is it acceptable to use a colon ":" to seperate statements in VBA?

strVar1 = "A": lngVar2 = 0: blnVar3 = True
Msgbox strVar1: Msgbox lngVar2: Msgbox blnVar3
I was going to say don't be so silly, but before I did, I tried:

Function test()

MsgBox "hi": MsgBox "hello": MsgBox "What cha doin?"

End Function

And I'll be a monkey's uncle, it works!!!

So I guess it's acceptable. 8) I would find it hard to read and follow
if I were looking at code, though.
--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "Be Careful, Big Bird!" - Ditto "TIM-MAY!!" - Me
Feb 16 '07 #3
I was surprised to see this work also, since the colon seemed to be
reserved to the GoTo or Resume statements. That's why I was wondering
if there would be problems?

As far as readability goes, there are instances (like initializations )
that would make for cleaner reading, rather than introducing some many
lines:

VarA=0: VarB=0: VarC=0: VarD=0
VarE=1: VarF=3: VarG=5: VarH=7
VarK=2: VarL=4: VarM=6: VarN=8

VarA=0
VarB=0
VarC=0
VarD=0
VarE=1
VarF=3
VarG=5
VarH=7
VarK=2
VarL=4
VarM=6
VarN=8
Etc............ ...

Feb 16 '07 #4
Ap******@gmail. com wrote:
>I was surprised to see this work also, since the colon seemed to be
reserved to the GoTo or Resume statements. That's why I was wondering
if there would be problems?

As far as readability goes, there are instances (like initializations )
that would make for cleaner reading, rather than introducing some many
lines:

VarA=0: VarB=0: VarC=0: VarD=0
VarE=1: VarF=3: VarG=5: VarH=7
VarK=2: VarL=4: VarM=6: VarN=8

VarA=0
VarB=0
VarC=0
VarD=0
VarE=1
VarF=3
VarG=5
VarH=7
VarK=2
VarL=4
VarM=6
VarN=8
Etc........... ....

That's about the only time I use it. Another is the cleanup
code:
rs.Close : Set rs = Nothing

--
Marsh
Feb 16 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
2003
by: adrien | last post by:
Hi, i start with javascript and i saw a lot of examples, but sometimes there is ";" on each end of line, sometimes only certain lines, sometimes nowhere. So my question is: where must i put ";" in a javascript (in function, out function)? thanks for help ad
21
3348
by: Evan Sussman | last post by:
Could any one give me an explenation of this error? I get it every once in a while, and it really is a pain. currently the code that I'm working with goes like this <script> <!-- var newwindow; function moviepopup(url) {
9
2189
by: Jukka K. Korpela | last post by:
I noticed that Internet Explorer (6.0, on Win XP SP 2, all fixes installed) incorrectly renders e.g. &harr &euro &Omega literally and not as characters denoted by the entities, but if a semicolon is appended to each of the entity references, they work. I'm pretty sure that previous versions of IE rendered them by the specifications. I first thought this has something to do with XML (i.e. maybe IE pretends to play a little bit of XML...
8
4430
by: Just Me | last post by:
1)How can I find the folders like "My Recent Document", "Desktop", "My Pictures",... if I want to store a file there? 2) How can I find the icon for those files if I want to display it? Thanks in advance for any helpful suggestions
43
2744
by: markryde | last post by:
Hello, I saw in some open source projects a use of "!!" in "C" code; for example: in some header file #define event_pending(v) \ (!!(v)->vcpu_info->evtchn_upcall_pending & \ !(v)->vcpu_info->evtchn_upcall_mask) whereas evtchn_upcall_pending is of type unsigned char (and also evtchn_upcall_mask is of type unsigned char).
3
1983
by: MLH | last post by:
If I run ?", ","" in the immediate window, I get a comma followed by 13 spaces. It is difficult for me to understand this.
1
2845
by: manchin2 | last post by:
Hi, Can anybody please provide the information about "&quot" and its use, if possible please provide an example. 1)<tm:bom-expression>{Conf.getEquityConfLookupFields().getEventFieldText(&quot;AdditionalDisruption&quot;,&quot;Change in Law&quot;)}</tm:bom-expression> 2)07:41:08 Default ( call ( . ( call ( . Conf getEquityConfLookupFields ) ) getEventFieldText ) ( , AdditionalDisruption Change inLaw ) ) value=Not applicable Can you please...
2
6776
by: Clint Stowers | last post by:
I have a query with a field name of "Street", however, I would like it to read "CAT:STREET". This query is exported to a csv file that requires the format of the later. Currently the csv file is modified manually after the fact. In the query I have been unable to create an expression that does not choke on the ":". Or is there a way to add the Header Field Name at the time of the TransferText?
4
3894
by: fran7 | last post by:
Hi, from help in the javascript forum I found the error in some code but need help. This bit of code works perfectly, trouble is I am writing it to a javascript function so the height needs to be in &quot;&quot; instead of "" otherwise I get an error message. Can anyone suggest how to write it so that it writes &quot; instead of "". I have tried all combinations of adding &quot; to the code but as soon as I think I am there I get throw out again. if...
0
9275
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10040
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9873
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9713
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8713
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7248
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6534
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5142
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2666
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.