Easy VB MsgBox question...

Status
Not open for further replies.

AER

Ars Tribunus Militum
2,410
Subscriptor++
This should be an easy question. (I am a moron who knows nothing about programming)
In MSVB 6, I want to make a MsgBox that displays multiple lines. According to the Help, I need to do this:
MsgBox(Prompt)
If prompt consists of more than one line, you can separate the lines using a carriage return character (Chr(13)), a linefeed character (Chr(10)), or carriage return - linefeed character combination (Chr(13) & Chr(10)) between each line.
I can't make this work. I get an error if I put it outside of the quotation marks (Do I need a concatenate function or something?), or I just get Chr(13) in my text in the message box.
So, how do I make this work? (Thanks in advance)
 
Actually, this is a bit less ambiguous:
code:<HR>
Code:
Const CRLF As String = Chr(13) & Chr(10)<P>Dim prompt1 As String
Dim prompt2 As String
Dim prompt3 As String<P>prompt1 = "first line"
prompt2 = "second line"
prompt3 = "third line"<P>MsgBox (prompt1 & CRLF & prompt2 & CRLF & prompt3)

The VB language reference says:
Remarks
When you use the + operator, you may not be able to determine whether addition or string concatenation will occur. Use the & operator for concatenation to eliminate ambiguity and provide self-documenting code.

Also, some versions of VB have interpreted "Dim prompt1, prompt2, prompt3 As String" as the definition of one String and two (implicit) Variants. While I'm not sure whether VB6 does that or not, it is still a good idea to spell it out.

Finally, Chr(13) & Chr(10) was made into the string constant CRLF.
 
Status
Not open for further replies.