Quoting inside a msgbox

Discussion in 'AutoCAD' started by KCGalloway, Jun 28, 2004.

  1. KCGalloway

    KCGalloway Guest

    I am trying to get a message box to display variables A, B, C... in the following format.

    (command "A" "B,C,D" "E,F,G")

    How do I write the VB code so this comming out correctl?
    Thank you.

    Best,

    Kevin
     
    KCGalloway, Jun 28, 2004
    #1
  2. Kevin, Try this.

    Paul

    Public Sub test()
    Dim lngRetval As Long
    Dim A As Variant: A = 10
    Dim B As Variant: B = 20
    Dim C As Variant: C = 30
    Dim D As Variant: D = "Fred"
    Dim quote As String
    quote = """"
    lngRetval = MsgBox( _
    quote & A & quote & " " & quote & B & "," & C & "," & D & quote, _
    vbOKOnly + vbInformation + vbDefaultButton1, _
    "<Type in your caption here>")

    Select Case lngRetval
    Case vbOK
    End Select
    End Sub
     
    Paul Richardson, Jun 28, 2004
    #2
  3. KCGalloway

    Warren M Guest

    Hello Kevin.

    Check out the CHR function...

    "This is a " & Chr(34) & "Quoted" & Chr(34) & " word"

    Or, another method is something like this:
    "This is a " & """" & "Quoted" & """" & " word"

    Hope this helps
    Warren M
     
    Warren M, Jun 28, 2004
    #3
  4. KCGalloway

    KCGalloway Guest

    Thanks guys. That helped a lot.

    Best,

    Kevin
     
    KCGalloway, Jun 28, 2004
    #4
  5. KCGalloway

    Ed Jobe Guest

    Note the following:
    MsgBox "This is a " & """" & "Quoted" & """" & " word"

    can be reduced to:
    MsgBox "This is a ""Quoted"" word"

    The important rule to remember is that, a double quote is a string delimiter. If you want to use it as a literal, you need an "escape character" (another double quote) which tells vb that the next single character is treated as a literal. Or it can be the result of an expression, such as Chr().
    --
    ----
    Ed
    ----
    Hello Kevin.

    Check out the CHR function...

    "This is a " & Chr(34) & "Quoted" & Chr(34) & " word"

    Or, another method is something like this:
    "This is a " & """" & "Quoted" & """" & " word"

    Hope this helps
    Warren M
     
    Ed Jobe, Jun 28, 2004
    #5
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.