String adaptation

Discussion in 'AutoCAD' started by Gilles, Apr 21, 2004.

  1. Gilles

    Gilles Guest

    Hi all,


    Is it possible to manipulate a string like this :

    Trasform the syntax below from :
    c:\\foldername01\\foldername02\\filename.dwg
    to
    c:\foldername01\foldername02\filename.dwg

    It's like a search (\\) and replace (\) in word or excell but in VBA...

    Thanks a lot in advance....


    Gilles
     
    Gilles, Apr 21, 2004
    #1
  2. Gilles

    Jean-Yves Guest

    You can use the Replace function :

    ....
    dim strResult as string

    strResult= Replace("c:\\foldername01\\foldername02\\filename.dwg", "\\",
    "\")
    .....


    Jean-Yves
     
    Jean-Yves, Apr 21, 2004
    #2
  3. Gilles

    Michel Guest

    Hi Gilles,

    Here's an example:
    Code:
    strInput = "c:\\foldername01\\foldername02\\filename.dwg"
    
    'split the string
    varItems = Split(strInput, "\\", , vbTextCompare)
    
    'rebuilt the string
    For i = LBound(varItems) To UBound(varItems)
    If i < UBound(varItems) Then
    strTransf = strTransf & varItems(i) & "\"
    Else
    strTransf = strTransf & varItems(i)
    End If
    Next i
    Please note that Split is not available in VB5.

    Michel
     
    Michel, Apr 21, 2004
    #3
  4. Gilles

    Gilles Guest

    Thanks a lot


    Gilles
     
    Gilles, Apr 21, 2004
    #4
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.