Stupid question: how do you add a line to a label?

UncleRonin

Well-known member
Joined
Feb 28, 2006
Messages
230
Location
South Africa
Programming Experience
5-10
Specifically, I want to display a message box with multiple lines (using MsgBox() ). For example:
"Hello Universe" with
"Cheerio" underneath... I remember that there is a line separator in the form of "\n" (or "/n" - can't remember). Is there a way to do this?
 
I would use vbCrLf, which is a constant containing two characters, carriage return and linefeed, which would create a new line. I am not sure if you can use "\n" in a message box.
 
vbCrLf always been good, but for readability I now prefer vbNewline
 
not that i know of, the massagebox class is pretty straight forward as to what you can and cant do...
 
Bleh... didn't think so *sigh* they should try and implement it with MessageBoxes in the future... I mean, EVERYONE uses MBoxes and the more flexible they are the better
 
Centering text

Here is the code to center a string max 80 char of text. You can change the 80 to a variable so you could base it however you want:

PublicSub CenterIt(ByRef fdata AsString)
Dim CData AsString
Dim strlen AsInteger
Dim X AsInteger
Dim EndOfLine, StartOfLine AsInteger
CData = Space(80)
strlen = fdata.Length
EndOfLine = 0
StartOfLine =
CInt((80 - strlen) / 2)
X = 1
CData = Space(StartOfLine)
DoUntil X = strlen + 1
CData = CData + Mid(fdata, X, 1)
X = X + 1
StartOfLine = StartOfLine + X
Loop
fdata = CData
EndSub:)
 
Last edited:
UncleRonin said:
Bleh... didn't think so *sigh* they should try and implement it with MessageBoxes in the future... I mean, EVERYONE uses MBoxes and the more flexible they are the better
You can also build your own.... MessageBoxes are meant to be simple and straightforward.... you add the ability to center the text, then people will want *some* of the text centered *some* of the time...... and where does it end?

-tg
 
Back
Top