Results 1 to 4 of 4

Thread: [RESOLVED] How to split this path location

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Resolved [RESOLVED] How to split this path location

    I have problem here, I have path location like this

    How to split this path location and only left its filename without extension *.shp


    CommonDialog4.InitDir = App.Path & "\export"
    CommonDialog4.Filter = shape
    CommonDialog4.DialogTitle = "Save selected feature"
    CommonDialog4.ShowSave
    outputfile = CommonDialog4.fileName
    Attached Images Attached Images  

  2. #2
    Hyperactive Member
    Join Date
    Jan 2008
    Location
    Merseyside
    Posts
    456

    Re: How to split this path location

    Try the Split Function.
    This code could be optimised better but here is a quick way to grab the filename.

    Code:
    Private Sub Form_Load()
    
        ' Declare Variables
        Dim path As String
        Dim firstsplit() As String
        Dim secondsplit() As String
    
        ' Filename
        path = "C:\PF\GUI\export\a.sph"
    
        ' Split by "\"
        firstsplit = Split(path, "\")
    
        ' Grab the full filename with extension and Split by "." 
        secondsplit = Split(firstsplit(4), ".")
    
        'Grab the filename
        MsgBox secondsplit(0)
    
    End Sub
    Last edited by kevchadders; Feb 8th, 2008 at 04:26 AM.

  3. #3
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: How to split this path location

    Code:
    CommonDialog4.InitDir = App.Path & "\export"
    CommonDialog4.Filter = Shape
    CommonDialog4.DialogTitle = "Save selected feature"
    CommonDialog4.ShowSave
    outputfile = CommonDialog4.FileName
    intI = InStrRev(outputfile, ".")
    If intI > 0 Then
        outputfile = Left$(outputfile, intI - 1)
    End If
    The above searches for a "." in the variable outputfile and then truncates outputfile to the character before the "."

  4. #4
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863

    Re: How to split this path location

    Funny, you asked the same a couple of month ago, got a solution and "Resolved" the thread!
    http://www.vbforums.com/showthread.php?t=493850
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

Posting Permissions

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



Click Here to Expand Forum to Full Width