Detach the file path, file name, and extension from the string

Source: Internet
Author: User
Tags exit integer

This function separates the path from the string

Function ParsePath (sPathIn As String) As String
  Dim I As Integer
  For I = Len(sPathIn) To 1 Step -1
   If InStr(":\", Mid$(sPathIn, I, 1)) Then Exit For
  Next
  ParsePath = Left$(sPathIn, I)
End Function

This function separates the file name from the string

Function ParseFileName (sFileIn As String) As String
  Dim I As Integer
  For I = Len(sFileIn) To 1 Step -1
   If InStr("\", Mid$(sFileIn, I, 1)) Then Exit For
  Next
  ParseFileName = Mid$(sFileIn, I + 1, Len(sFileIn) - I)
End Function

This function separates the file name extension from the string

Function GetFileExt (sFileName As String) As String
  Dim P As Integer
  For P = Len(sFileName) To 1 Step -1
   If InStr(".", Mid$(sFileName, P, 1)) Then Exit For
  Next
  GetFileExt = Right$(sFileName, Len(sFileName) - P)
End Function

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.