Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Too many Line continuations

Status
Not open for further replies.

Mungovan

Programmer
Oct 24, 2002
94
IE
hi,
I have a string in my VB code. When assigning a value to it I get an error saying that I have too many line continuations. I can't get around this because I need all of the lines. Any ideas of how to get out of this?

------------------------------
myString = "xxxxxxxxxx" & _
"yyyyyyyyyy" & _
.....
.....
.....
------------------------------

Thanks,
D

 
The compiler is refering to the number of "& _"'s that you are using not the number of "&" that you are using. So just combine every other line like this.

myString = "xxxxxxxxxx" & "yyyyyyyyyy" & _
"....." & "....." & _
.....

making three line continuations rather than five.

good luck,
KCI

Our greatest glory consists not in never falling, but in rising every time we fall.
Confucious
 
Thanks,
Is there any way of getting around this, basically I'll need to concantinate over 100 lines of code!!

Thanks,
D
 
Yes, use multiple variable like this.

a = "1" & "2"

b = a & "3" & "4"

c = b & "5" & "6"

d = c & "7" & "8"

?d
"12345678"

good luck
KCI

And there comes a time when one must take a position that is neither safe, nor political, nor popular, but he must take it because his conscience tells him that it is right.
Martin Luther King
 
i've solved this problem in other ways. my favourite technique is to take the information from a text file or resource string. what is the code?
 
KCI's method works, but has the drawback of needing many temp variables. Try this instead:
Code:
str = ""
str = str & "xxxxxxxxx"
str = str & "yyyyyyyyy"
str = str & "zzzzzzzzz"
By doing it this way you only need one variable.

Chip H.
 
Point well taken. Chip H. is absolutely correct. His suggestion will be much faster since OS paging will be minimized. (Good eye Chip). ;)~

KCI

No day in which you learn something is a complete loss.
David Eddings
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top