Continuing code on a new line in a module.

JUDO

Registered User.
Local time
Today, 18:22
Joined
Aug 21, 2003
Messages
26
How can you continue code within a module on a new line?
 
Code:
You can do it by using the _
character at the end of _
a line or wherever you _
want.
 
Mile-O-Phile said:
Code:
You can do it by using the _
character at the end of _
a line or wherever you _
want.

Mile,

just to expand,

to stretch a string over more than one line you need to close the string at the end of each line. This is to allow the compiler to see the _. if you dont do this the _ is just seen as text in the string and an error will occure on the following lines.

ie

Code:
str = "select * " & _
           "From Sometable " & _
           "Where SomeFiled = 'xyz'"


Another one to look out for, Expecialy when using this method to split Sql statements in to lines(in code), is the existance of
spaces between lines.
 
And:

you can do it with comments too

ie.

Code:
Debug.Print "Mile-O-Phile" ' This prints _
 out my screen name _
 so you can see it
 

Users who are viewing this thread

Back
Top Bottom