Results 1 to 10 of 10
  1. #1
    Join Date
    Aug 2003
    Posts
    123

    Red face Unanswered: Command for carriage return?

    Real dumb question: I've seen a command somewhere to get a long line of text displayed as two lines, like on a Message Box. Something like "vbCrRtrn"?

    So my long text could be:

    string & vb?? & string2

  2. #2
    Join Date
    Nov 2005
    Posts
    113
    msgBox "same text" & vbCrLf & "another text"

  3. #3
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    Julita has the right idea, however you must first assign the message to a string variable, then use the variable in the msgbox function, like this:

    Code:
    Dim strMsg as String
    
    strMsg = "NO SUCH ID" & vbCrLf & "WOULD YOU LIKE TO RETRY SEARCH ?"
                  
    Response = (MsgBox(Msg, vbRetryCancel,"ID Not Found !"))
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  4. #4
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    Sorry, that last line of code should be:

    Code:
    Response = (MsgBox(strMsg, vbRetryCancel,"ID Not Found !"))
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  5. #5
    Join Date
    Aug 2003
    Posts
    123
    Yup, that was it. Thanks both.

  6. #6
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    You can also use vbNewLine instead of vbCrLf

  7. #7
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    True, or (Chr(13) & Chr(10)) as well!

    As my signature states:

    There's always more than one way to skin a cat!
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  8. #8
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    There's always more than one way to skin a cat!
    ...whilst we are messing around
    Julita's original proposal works fine too.

    izy
    currently using SS 2008R2

  9. #9
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    So it does, izy!
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  10. #10
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    You don't need to assign a message to a string variable to display a message or to use the vbcrlf to display the message box on mulitple lines. The only time you need a string (or other) variable is if you're expecting a response.
    i.e.
    Dim QI As Integer
    QI = MsgBox("Are you sure?", vbYesNo)
    If QI = 6 Then
    MsgBox "You said yes." & vbCrLf & "And clicked the Yes button."
    Else
    MsgBox "You said No." & vbCrLf & "And clicked the No button."
    End If

    Don't waste defining a variable unless you really need to.
    Last edited by pkstormy; 10-04-06 at 23:18.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •