The Design of Software (CLOSED)

A public forum for discussing the design of software, from the user interface to the code architecture. Now closed.

The "Design of Software" discussion group has been merged with the main Joel on Software discussion group.

The archives will remain online indefinitely.

VB6: line continuations

Hi.  I have a couple of questions on lines of string in VB.
What’s the difference between using:
    “Hello ” & _
    “world”
and
    “Hello ” _
    “world”
to break between lines?

Is it better to have massively long lines, or better to break the lines up.  And then which is best, the “&_” or “_”?
I’ve ran into “too many line continuations” errors (which is sorted out now) but I would like to know why there is such an error in VB.

Or is it better do go a totally different route and do this:
sString = "Hello "
sString = sString & "world"
?
Celeste L Send private email
Wednesday, November 02, 2005
 
 
You should use the & and assign the string only once.

The “Hello ” _
    “world”

will give you an error.  The syntax is not correct.  You always have to have the & like

“Hello ” & _
    “world”

The following is not advised either since you are assigning a variable twice which requires the variables memory to be allocated twice:

sString = "Hello "
sString = sString & "world"

Use this:
“Hello ” & _
    “world”
Nick Koranda Send private email
Wednesday, November 02, 2005
 
 
1.  Yes, you want to break lines up into lines of less than 80 characters.  This makes creating a listing, and editing those lines on a monitor, much easier.

2.  Yes, "& _" is the best way to concatenate long text lines across multiple lines.

3.  I've only run into "too many continuations" once.  The solution was to write something like:

MyStr = "yadda, yadda, yadda, " & _
  "yadda, yadda, .." & _
etc, until I had like 8 lines of continuations.  Then:

MyStr = MyStr & _
"more yadda, yadda, yadda..." & _

etc.

Another solution to this is to create a text file with the desired text, then read that file into a text variable on the fly when your program loads.
AllanL5
Wednesday, November 02, 2005
 
 
Or use a text resource.
walter mitty
Wednesday, November 02, 2005
 
 
Dont think I'll go the text file route, its for passing parameters to stored procs.  (Easier to debug later when each item is in it's own row.)

Anyway, thanks for the help!
Celeste L Send private email
Thursday, November 03, 2005
 
 

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
 
Powered by FogBugz