Solved

Split Code from single line to multiple line

Posted on 2011-09-18
7
365 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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
MsgBox 4 68
Cygwin - GNU GPL License 1 34
SQL Insert parts by customer 12 42
Developing database that gets updated from Excel. Looking for best approach 5 39
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
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.
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 …
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…

789 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