locked
How To Create Multiple Lines Within A Message Box

    Question

  • How do you create multiple lines within a message box when combining a string with variable values?

    I know... it would probably be easier to just create a seperate form and load the form.... just wondering if it was possible to not have to do such though. What if the data that is to appear on the next line is - lets say - the value of an array.

    I'll explain my question. What if I want to display a list of values which the user entered....not for confirmation purposes but just to show what data had been entered...into a declared array. So..


    Dim intArray(5) As Integer

    Element# Element Value
    0 = 11
    1 = 22
    2 = 33
    3 = 44
    4 = 55


    Now ...lets say I want a message box to appear after all the input and display something like this:

    YOU ENTERED:
    11
    22
    33
    44
    55

    Saturday, June 17, 2006 7:54 PM

Answers

  • MessageBox.Show("YOU ENTERED:" & intArray(0) & Chr(10) & intArray(1))
    Or :
    MessageBox.Show("YOU ENTERED:" & intArray(0) & vbCrLf & intArray(1))
    Saturday, June 17, 2006 7:59 PM

All replies

  • MessageBox.Show("YOU ENTERED:" & intArray(0) & Chr(10) & intArray(1))
    Or :
    MessageBox.Show("YOU ENTERED:" & intArray(0) & vbCrLf & intArray(1))
    Saturday, June 17, 2006 7:59 PM
  • Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    Dim intArray(5) As Integer

    Dim mess As String = ""

    intArray(0) = 11

    intArray(1) = 22

    intArray(2) = 33

    intArray(3) = 44

    intArray(4) = 55

    For x As Integer = 0 To intArray.GetUpperBound(0) - 1

    mess = mess & intArray(x).ToString & vbCrLf

    Next

    MsgBox("You Entered " & vbCrLf & mess)

    End Sub

    Saturday, June 17, 2006 8:09 PM
  • Thanks yall for the help....both examples were exactly what I was looking for
    Monday, June 19, 2006 2:00 AM
  • Glad you found some help, but you should post your thanks on the same thread, not in a new one.  That way, the people who helped you will see your reply.  You've only made two posts, so I can tell this time where to move this.

     

    Monday, June 19, 2006 2:20 AM
  • You should not use vbCrLf, you should use Environment.NewLine.  vbCrLf is a holdover from VB6.

     

    Monday, June 19, 2006 2:21 AM
  • thought i had... navigation is a bit strange for me
    Monday, June 19, 2006 3:13 AM
  • No worries.  The 'reply' button goes to the thread, the 'new thread' button starts a new one.

     

    Monday, June 19, 2006 3:16 AM