#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2003
    Posts
    24
    Rep Power
    0

    Easy VB Question


    Hello,

    I'm trying to assign a string such as "Hello World" to a variable. The trick is, is that I also want to include the quotes around the string. How can this be done in VB?

    I know in C/C++/Java, you just use escape characters so you can make an assignment like
    "\"Hello World\""

    How do you do that in VB?

    Thank-you
  2. #2
  3. Contributing User
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jan 2003
    Location
    USA
    Posts
    7,184
    Rep Power
    2222
    Just drawing on my old experience with BASIC -- I have made a few half-hearted stabs at VB, only to be frustrated by the development environment and and end up home-sick for the expressiveness of C++.

    We used to be able to use either single quotes or double quotes to create a string literal. You could try (spaces inserted to separate the quote marks):
    ' "Hello, World" '

    If that doesn't work, then you could try doubling the quotemarks:
    ""Hello, World"" (" "Hello, World" ")
  4. #3
  5. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Location
    Canada - Egypt
    Posts
    60
    Rep Power
    12
    double the double qoutes is how u escape it in VB

    so
    x = """Hello World"""
    should do

    or use the chr() function but I am not sure exactly what was the number for qoute

    but assuming it is y

    x = chr(y) & "Hello World" & chr(y)
    I hope this is of any help to anyone.

    Yassoor
    http://www.WebsitesCreation.ca

IMN logo majestic logo threadwatch logo seochat tools logo