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

Multiple Lines in a Message Box

Status
Not open for further replies.

NewfieGolfer

Technical User
Mar 29, 2001
80
0
0
CA
Hi,
I was wondering if it's possible to display multiple lines in a message box..

I need the message box to display information that is inputted on a form. Once the user is finished entering information in the form, they click a button. Then the message box with the information the user entered on the form is displayed. This is for verification purposes before making changes.

So it should look like this (just an example):
____________________
ID: User ID
Name: Name
Address: Address
___ ______
|OK | |Cancel|
____________________

The message box will have an OK and Cancel button. I can get it to display in one line only but I would like multiple lines.

Can someone help?
Thanks,
NG

 
Sure, just use the vbCrLf character to display multiple lines.


Dim strText as string

strText = "Line 1" & vbCrLf & "Line 2" & vbCrLf & "Line 3"
msgbox strText Maq [americanflag]
<insert witty signature here>
 
NG,

You'll need to use vbCrLf (visual basic carriage return line feed).

You can do it like this:
Call MsgBox(&quot;Something&quot; & vbCrLf & &quot;Something Else&quot;)

If you don't get it to work the way you want, post the code you're using and we'll be able to tweak it for you.

Jeremy =============
Jeremy Wallace
AlphaBet City Dataworks

Take a look at the Developers' section of the site for some helpful fundamentals.
 
msgbox &quot;ID: &quot; & UserID & vbcrlf & vbcrlf & &quot;Name: &quot; & Name & vbcrlf & vbcrlf & &quot;Address: &quot; & Address, vbOKCancel

this assumes that UserID, Name, and Address are defined variables that hold the value you want to display in the message. Each vbcrlf will give you a new line. And, if you want to add a caption to the message box follow all that with a
comma and caption in quotes e.g.

, &quot;CaptionHere&quot;
 
Hi NewfieGolfer

Sub ShowMsgBox()
Dim myMsg As String, UserID
Dim Name, Address
myMsg = &quot;ID: &quot; & UserID
myMsg = myMsg & Chr$(13) & &quot;Name: &quot; & Name
myMsg = myMsg & Chr$(13) & &quot;Address: &quot; & Address
Msgbox myMsg, vbOKCancel, &quot;Title of your Msgbox&quot;
End

Hope this helps.

rgds
LSTAN


 
NewfieGolfer ...
While all the posts above work great, i think it more standard to use the VbCrLf example. It is just easier to read.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top