Solved

Split Code from single line to multiple line

Posted on 2011-09-18
7
369 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
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?
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…

740 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