Consulting

Results 1 to 6 of 6

Thread: Part of a string

  1. #1
    VBAX Regular
    Joined
    Aug 2019
    Posts
    42
    Location

    Part of a string

    Hi to everyone
    I have this string "E:\Ksilenio Projects\Example\ProjectID_12\ytko.SL" and i want to use the string except the last part "\ytko.SL".How can i do it?
    Thank you for your time
    Kostas

  2. #2
    VBAX Mentor
    Joined
    Dec 2008
    Posts
    343
    Location
    Sub AAA()
      Dim OldString As String
      Dim NewString As String
      Dim lPos As Long
      
      OldString = "E:\Ksilenio Projects\Example\ProjectID_12\ytko.SL"
      lPos = InStrRev(OldString, "\")
      NewString = Left(OldString, lPos - 1)
      
      MsgBox "Original string:" & vbLf & OldString & vbLf & "New string:" & vbLf & NewString
    End Sub
    Artik

  3. #3
    VBAX Regular
    Joined
    Aug 2019
    Posts
    42
    Location
    OK Thank you Artik

  4. #4
    VBAX Regular
    Joined
    Aug 2019
    Posts
    42
    Location
    Hi i have another question
    How can i take the right part of string (ytko.SL)
    Thank you for your time
    Kostas


  5. #5
    VBAX Mentor
    Joined
    Dec 2008
    Posts
    343
    Location
      NewString = Mid(OldString, lPos + 1)
    Or
      NewString = Right(OldString, Len(OldString) - lPos)
    Artik

  6. #6
    VBAX Regular
    Joined
    Aug 2019
    Posts
    42
    Location
    OK Thank you very much for your help Artik

Posting Permissions

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