Solved

Split Code from single line to multiple line

Posted on 2011-09-18
7
364 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 25 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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
LVL 76

Accepted Solution

by:
GrahamSkan earned 25 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

776 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