Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Split Code from single line to multiple line

Posted on 2011-09-18
7
Medium Priority
?
376 Views
Last Modified: 2012-05-12
HI
I am using following code and its working fine,
Print #iFileNo, Text1.text & ";" & Combo2.text & ";" & DTPicker1.Value & ";" & Text21.text & ";" & 0 & ";" & Text4.text & ";" & Text5.text & ";" & Text2.text & ";" & Text3.text & ";" & Text8.text & ";" & Text9.text & ";" & Text10.text & ";" & Text12.text & ";" & TopyAmt & ";" & PadAmt & ";" & Combo1.text & ";" & Text27.text & ";" & Text28.text & ";" & Text33.text & ";" & Text30.text & ";" & Text29.text & ";" & Text37.text & ";" & Text14.text & ";" & Text13.text & ";" & Text15.text & ";" & 0 & ";" & Text19.text & ";" & 0 & ";" & Text23.text & ";" & ctgrp & ";" & Text24.text & ";" & 0 & ";" & 0 & ";" & dummyDate & ";" & Text36.text & ";" & Text40.text & ";" & 0 & ";" & 0 & ";" & dummyDate & ";" & Text11.text & ";" & TotTopyAmt & ";" & TotPadAmt & ";" & 0 & ";" & 0 & ";" & 0 & ";" & 0 & ";" & Text7.text & ";" & Combo3.text & ";" & Text17.text & ";" & Text18.text & ";" & Combo7.text & ";" & Text32.text & ";" & Text31.text & ";" & Text60.text & ";" & 0 & ";" & Text58.text & ";" & Text59.text

Open in new window


what i want is,  this is long line code i want it to be multiple line using.
I tried using " & _
but its adding another space in second line.. like this, will it work. if not then what am i doing wrong.
Print #iFileNo, Text1.text & ";" & Combo2.text & ";" & DTPicker1.Value & ";" & Text21.text & ";" & 0 & ";" & Text4.text & ";" & Text5.text & ";" & Text2.text & ";" & Text3.text & ";" & Text8.text & ";" & Text9.text & ";" & Text10.text & ";" & Text12.text & ";"; " &" _
; "& TopyAmt & "; " & PadAmt & "; " & Combo1.text & "; " & Text27.text & "; " & Text28.text & "; " & Text33.text & "; " & Text30.text & "; " & Text29.text & "; " & Text37.text & "; " & Text14.text & "; " & Text13.text & "; " & Text15.text & "; " & 0 & "; " & Text19.text & "; " & 0 & "; " & Text23.text & "; " & ctgrp & "; " & Text24.text & "; " & 0 & "; " & 0 & "; " & dummyDate & "; " & Text36.text & "; " & Text40.text & "; " & 0 & "; " & 0 & "; " & dummyDate & "; " & Text11.text & "; " & TotTopyAmt & "; " & TotPadAmt & "; " & 0 & "; " & 0 & "; " & 0 & "; " & 0 & "; " & Text7.text & "; " & Combo3.text & "; " & Text17.text & "; " & Text18.text & "; " & Combo7.text & "; " & Text32.text & "; " & Text31.text & "; " & Text60.text & "; " & 0 & "; " & Text58.text & "; " & Text59.text"

Open in new window


actually i don't have time to test, i need to just apply and compile at client side..
0
Comment
Question by:crystal_Tech
  • 6
7 Comments
 
LVL 47

Assisted Solution

by:for_yan
for_yan earned 100 total points
ID: 36557549
Break code not inside the quoted string in this way:
(see
http://msdn.microsoft.com/en-us/library/ba9sxbw4.aspx)

cmd.CommandText = _
    "SELECT * FROM Titles JOIN Publishers " _
    & "ON Publishers.PubId = Titles.PubID " _
    & "WHERE Publishers.State = 'CA'"

0
 
LVL 47

Expert Comment

by:for_yan
ID: 36557552


To break a single statement into multiple lines

    Use the line-continuation character, which is an underscore (_), at the point at which you want the line to break. The underscore must be immediately preceded by a space or a line terminator (carriage return). In some cases, you can omit the line-continuation character and the Visual Basic compiler will implicitly continue the statement on the next line of code. For a list of syntax elements for which the line-continuation character can be omitted, see "Implicit Line Continuation" in Statements in Visual Basic.

    In the following example, the statement is broken into four lines with line-continuation characters terminating all but the last line.
0
 
LVL 47

Expert Comment

by:for_yan
ID: 36557557


Also important:

The line-continuation character is necessarily the last thing on a line. You cannot follow it with anything else on the same line.

Some limitations exist as to where the line-continuation character can be used, such as in the middle of an argument name. You can break an argument list with the line-continuation character, but the individual names of the arguments must remain intact.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 76

Accepted Solution

by:
GrahamSkan earned 100 total points
ID: 36557562
Just remember that you can't split a line in the middle of a string.

Print #iFileNo, Text1.text & ";" & Combo2.text & ";" & DTPicker1.Value & ";" & Text21.text & ";" & 0 & _
";" & Text4.text & ";" & Text5.text & ";" & Text2.text & ";" & Text3.text & ";" & Text8.text & ";" & _
Text9.text & ";" & Text10.text & ";" & Text12.text & ";" & TopyAmt & ";" & PadAmt & ";" & Combo1.text & _
";" & Text27.text & ";" & Text28.text & ";" & Text33.text & ";" & Text30.text & ";" & Text29.text & ";" & _
Text37.text & ";" & Text14.text & ";" & Text13.text & ";" & Text15.text & ";" & 0 & ";" & Text19.text & _
";" & 0 & ";" & Text23.text & ";" & ctgrp & ";" & Text24.text & ";" & 0 & ";" & 0 & ";" & dummyDate & ";" & _
Text36.text & ";" & Text40.text & ";" & 0 & ";" & 0 & ";" & dummyDate & ";" & Text11.text & ";" & _
TotTopyAmt & ";" & TotPadAmt & ";" & 0 & ";" & 0 & ";" & 0 & ";" & 0 & ";" & Text7.text & ";" & Combo3.text _
& ";" & Text17.text & ";" & Text18.text & ";" & Combo7.text & ";" & Text32.text & ";" & Text31.text & ";" & _
Text60.text & ";" & 0 & ";" & Text58.text & ";" & Text59.text

Open in new window

0
 
LVL 47

Expert Comment

by:for_yan
ID: 36557565
I think like that:

....& Text12.text & ";" _
&  TopyAmt & "; .... 

Open in new window

0
 
LVL 47

Expert Comment

by:for_yan
ID: 36557571

Little bit more clear, but the same point
....& Text12.text & ";" _
&  TopyAmt & ";" &  .... 

Open in new window

0
 
LVL 47

Expert Comment

by:for_yan
ID: 36557579

That's how you break - from this
... & Text12.text & ";" & TopyAmt & ";" & PadAmt....

Open in new window


to this:

... & Text12.text & ";" _
& TopyAmt & ";" & PadAmt....

Open in new window

0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
What do responsible coders do? They don't take detrimental shortcuts. They do take reasonable security precautions, create important automation, implement sufficient logging, fix things they break, and care about users.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Progress

824 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question