The filename has two varients:
L:\MMpdf\ConsoleFiles\98754\98754-01.jpg
(Extracted Result should be: 98754)
or
L:\MMpdf\ConsoleFiles\987540\987540-001.jpg
(Extracted Result should be: 987540)
The character causing the difficulty is the "-"
Code: Select all
Private Sub Command2_Click()
Dim posn As Integer, i As Integer
Dim fName As String
Dim GetFilename As String
posn = 0
For i = 1 To Len(txtJob)
If (Mid(txtJob, i, 1) = "-") Then posn = i
Next i
fName = Right(txtJob, Len(txtJob) - posn)
posn = InStr(fName, ".")
If posn <> 0 Then
fName = Left(fName, posn - 1)
End If
GetFilename = fName
MsgBox fName
End Sub