Results 1 to 8 of 8

Thread: How to put a literal quote " in a msgbox

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2004
    Posts
    1

    Question How to put a literal quote " in a msgbox

    OK, I'm a newbie here and am just learning VB.....

    I want to literally put a " (a quote) in a Msgbox...how can I get VBscript to recognize that I just want a " in the MSGbox and it is not the beginning of a string?

    for example...

    The following code in a .vbs file:
    Msgbox "


    Returns an error "unterminated string constant". But I literally want a message box with a double quote mark in it. How do you do it?

    Thanks,
    Bookoo

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    Use Chr(34)

  3. #3
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629
    "" works also.

  4. #4
    PowerPoster Arc's Avatar
    Join Date
    Sep 2000
    Location
    Under my rock
    Posts
    2,336
    MsgBox """asdfsdfsdf"""
    -We have enough youth. How about a fountain of "Smart"?
    -If you can read this, thank a teacher....and since it's in English, thank a soldier.


  5. #5
    Frenzied Member
    Join Date
    May 2003
    Location
    So Cal
    Posts
    1,564
    Think you have to use

    Msgbox """" asd """"

    Originally posted by Arc
    MsgBox """asdfsdfsdf"""

  6. #6
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    Originally posted by BrianS
    Think you have to use

    Msgbox """" asd """"
    VB Code:
    1. Private Sub Command1_Click()
    2.     MsgBox """" & "asd" & """"
    3. End Sub
    -= a peet post =-

  7. #7
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171
    Or make it a constant :

    VB Code:
    1. Const Quotes As String = """"
    2.  
    3. MsgBox Quotes & "text" & Quotes

    Makes it easier to read...


    Has someone helped you? Then you can Rate their helpful post.

  8. #8
    Hyperactive Member DarkX_Greece's Avatar
    Join Date
    Jan 2004
    Location
    Athens (Greece)
    Posts
    315

    There are two ways to do it

    First way:

    msgbox "Hello ""Test"" Good bye"


    Second way:

    msgbox "Hello " & chr(34) & "Test" & chr(34) & " Good bye"

    It will look like this:
    Hello "Test" Good bye


    I hope this is want you need.
    Short CV:
    1. Visual Basic 6 Programmer
    2. Web Expert


    Botonakis Web Services

Posting Permissions

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



Click Here to Expand Forum to Full Width