New line in VBA

  • Thread starter Thread starter Mo
  • Start date Start date
M

Mo

Hello All,

I'm trying to avoid having immensely long lines of code that go on past
the edge of the screen so that I have to keep scolling across to see the
end of the code.

Is there any syntax that allows me to move to new line and simply
concatenates the new line to the previous line?

Thanks very much,

Mo
 
"Mo" wrote in message news:frb8ek$uer$1@qmul...
Hello All,

I'm trying to avoid having immensely long lines of code that go on past
the edge of the screen so that I have to keep scolling across to see the
end of the code.

Is there any syntax that allows me to move to new line and simply
concatenates the new line to the previous line?


The underscore character (_) may be used as a line continuation character.
You can end one line at a natural break -- the end of a word or a comma --
tack on a space and underscore, and continue anywhere you want on the next
line. For example,

X = A + B _
+ C

DoCmd.OpenForm _
"MyForm", _
acNormal, _
, _
"ID=27"

strSQL = _
"SELECT Field1, Field2, Field3 " & _
"FROM MyTable " & _
"WHERE Field4 > 42"
 
End the line(s) to be continued with an underscore (_) and continue the
statement on the next line. I have found that the underscore must have a
space before it.

For example:

MsgBox Err.Description, vbExclamation, _
"MS Access Error " & Err.Number

John

Hello All,

I'm trying to avoid having immensely long lines of code that go on past
the edge of the screen so that I have to keep scolling across to see the
end of the code.

Is there any syntax that allows me to move to new line and simply
concatenates the new line to the previous line?

Thanks very much,

Mo

--
John Goddard
Ottawa, ON Canada
jrgoddard at cyberus dot ca

Message posted via AccessMonster.com
 
Back
Top