Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Character to write multiple lines on one line?

Status
Not open for further replies.

Ahliana

Programmer
Sep 4, 2002
27
0
0
US
Hey, a simple question! I can't find or remember the character to allow you to put more than one command on a single line of code. It doesn't seem to be a semicolon or a colon. I last did this many years ago, but it would be helpful at the moment.

Example (pretending the character is a colon):
Code:
With rs: .AddNew: .rs.Fields("X") = 0: .Update: End With
Does anybody remember the errant character? Thanks!

Ahliana
Argue for your limitations and, sure enough, they're yours! - Richard Bach
 
With rs
.AddNew
.Fields("X") = 0
.Update
End With

No need for a special character. If you are needing to extend a code line over multiple lines, the _ is the correct symbol. For instance:

StringVar = "This is going to be a really long line " & _
"so I'll carry it over to the next line."

I am what I am based on the decisions I have made.

DoubleD [bigcheeks]
 
Colon works for me:
Code:
For n = 1 to 4 : Debug.Print n : Next n
But please don't do this. Multiple statements on one line were necessary evil twenty years ago when we had a limited number of lines but they just make code harder to read.

Geoff Franklin
 
With all due respect Geoff, in most cases it does make code harder to read, but in others....


rec.Close: set rec = Nothing

Select Case Month(txtDate)
Case 1: x = "January"
Case 2: x = "February"
Case 3: x = "March"
End Select

If x Mod 2 = 0 Then bRemove = True: Exit Sub

Just my 2 cents. I'm a little partial to brevity in code sometimes, because a find, at my level, it gets a little daunting, if it's too long winded. (I love the looping structures, LOL).

But most programmers agree, the more "abbreviated" the code, the harder to read.

Good luck either way!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top