Consulting

Results 1 to 3 of 3

Thread: Using character that are used by VBA

  1. #1
    VBAX Newbie
    Joined
    Mar 2005
    Posts
    3
    Location

    Using character that are used by VBA

    Hi,

    Me.PiclocA.Value = "c:\\pictures\\" + a + "\\" + "a.jpg"

    I want to add a set of quotes round the text like this

    Me.PiclocA.Value = ""c:\\pictures\\" + a + "\\" + "a.jpg""

    However as quotes are part of the language it will not let me do it in VBA. How do I put the quotes in and make the language read them as text?

    Thanks

  2. #2
    VBAX Master Norie's Avatar
    Joined
    Jan 2005
    Location
    Stirling, Scotland
    Posts
    1,831
    Location
    What do you actually want to put quotes around? It isn't clear from your post

    By the way it is possible to do it.
    You can either use multiple quotes """ or Chr(34).

  3. #3
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Hi John,
    Norie is quite right, but having dealt with multiple quotes in SQL code, it's easy to make a mistake. Try something like the following (names changed just to get the sub to run):
    [VBA]
    Sub nn()
    a = "Test"
    PiclocA = "c:\\pictures\\" + a + "\\" + "a.jpg"
    Debug.Print PiclocA
    pic1 = "c:\\pictures\\"
    pic2 = "\\"
    pic3 = "a.jpg"
    PiclocA = Chr(34) + pic1 + a + pic2 + pic3 + Chr(34)
    Debug.Print PiclocA

    End Sub
    [/VBA]

Posting Permissions

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