1 Attachment(s)
[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
Quote:
CommonDialog4.InitDir = App.Path & "\export"
CommonDialog4.Filter = shape
CommonDialog4.DialogTitle = "Save selected feature"
CommonDialog4.ShowSave
outputfile = CommonDialog4.fileName
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
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 "."
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