Character Codes

  • Thread starter Thread starter Tim
  • Start date Start date
T

Tim

Hello,

I am trying to dynamically change the labels on a group
of buttons on a form. It is a calendar with event
descriptions on a button for each day. I have the code all
set up, but I want to use three lines of text on each
button. I have used Chr(13) to do a carriage return. All
that gives me is the filled in block that represents a
return though, not an actual new line. It does the same
with the linefeed character Chr(10). If I type directly
into the button and hit Control-Return it will put a true
carriage return in the text (I used the ASC() function to
verify that it is Chr(13)). Is there some way to insert a
carriage return through VBA code? Thanks

Tim
 
I am trying to dynamically change the labels on a group
of buttons on a form. It is a calendar with event
descriptions on a button for each day. I have the code all
set up, but I want to use three lines of text on each
button. I have used Chr(13) to do a carriage return. All
that gives me is the filled in block that represents a
return though, not an actual new line. It does the same
with the linefeed character Chr(10). If I type directly
into the button and hit Control-Return it will put a true
carriage return in the text (I used the ASC() function to
verify that it is Chr(13)). Is there some way to insert a
carriage return through VBA code? Thanks

You need to use both Chr(13) and Chr(10), and in that order, or one of the
intrinisc constants, such as vbNewLine or vbCrLf (the constants can only be used
from within VBA):

Me.lblText.Caption = "This is line 1 and" & _
Chr(13) & Chr(10) & "this is line 2."

.... or ...

Me.lblText.Caption = "This is line 1 and" & _
vbCrLf & "this is line 2."

.... or ...

Me.lblText.Caption = "This is line 1 and" & _
vbNewLine & "this is line 2."
 
Back
Top