Book Home Page Bloglines 1906 CelebrateStadium 2006 OfficeZealot Scobleizer TechRepublic AskWoody SpyJournal Computers Software Microsoft Windows Excel FrontPage PowerPoint Outlook Word Host your Web site with PureHost! |
Thursday, October 26, 2017 – Permalink – Insert Line Breaks With CodeLabel CaptionsIf you've ever needed to insert line breaks in a message box prompt, you most likely built a string that incorporated a line feed or carriage return character. Unfortunately, label objects aren't as forgiving when it comes to using these characters. If you're setting a label's Caption property with code, you'll find that the special control characters are interpreted as squares, since they're otherwise un-displayable. To successfully insert a line break in a label caption, you need to include both a line feed character and a carriage return character, entered consecutively. To do so, you can use the Chr() function, such as: Me.Label1.Caption = "Line 1" & _ Chr(13) & Chr(10) & "Line 2" However, you can also simplify your code using an built-in constant: Me.Label1.Caption = "Line 1" & vbCrLf & "Line 2" See all Topics excel Labels: Formats, Functions, General, Reference, Shortcuts, Tips, Tutorials <Doug Klippert@ 3:08 AM
Comments:
Post a Comment
|