Solved

Split Code from single line to multiple line

Posted on 2011-09-18
7
362 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
A short article about problems I had with the new location API and permissions in Marshmallow
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

757 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now