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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

New Line in label, Chr(13) not working. 2

Status
Not open for further replies.

grande

Programmer
Feb 14, 2005
657
CA
In the past, I have made a newline on a MsgBox by using Chr(13). Now I'm trying to put a new line onto a label, and all I'm getting is a box, and the text continues along the same line.

Am I doing something wrong, or is there a way around this?

-------------------------
Just call me Captain Awesome.
 
I've always used the chr(10) & chr(13) for a new line + carriage return (actually, I prefer VBA's vbcrlf).

< M!ke >
 
A new line in a label is created by two characters, ASC 13 and ASC 10. Try creating a label on a test form, called lblTest1. Make this tall enough to hold two lines of text.

Now create a command button on the form, and write this code into its On_Click event:
Code:
Me.lblTest1.Caption = "Line One" & Chr$(13) & Chr$(10) & "Line Two"
Access VBA has a built in 'New Line' constant, containing these two characters, which you can use for convenience:
Code:
Me.lblTest1.Caption = "Line One" & vbNewLine & "Line Two"

I hope this is useful.

Bob Stubbs
 
You'll probably have to use [tt]vbCrLf or vbNewLine[/tt] to make it format properly.

VBSlammer
redinvader3walking.gif

"You just have to know which screws to turn." - Professor Bob
 
Yeah, I ended up using vbCrLf. Thanks guys!

-------------------------
Just call me Captain Awesome.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top