motoburn
Member
I am getting an error on compilation for the Right() and Left() sections of this. I borrowed this function from another site earlier today (been all over so I dont remember where) I needed this function to strip the directory and extension off a file name so i could use the filename as a field in a database table.
The error states:
and the function is :
I am using VS 2008 and VB.Net and building a Windows Forms application to search a specific directory and harvest data from excel files generated by a new machine on the production line... and help would be greatly appreciated.

thanks
The error states:
VB.NET:
Error 1 'Public ReadOnly Property Right() As Integer' has no parameters and its return type cannot be indexed.
~\WindowsApplication1\mtI1.vb 29 17 MotoTally
Error 2 'Public Property Left() As Integer' has no parameters and its return type cannot be indexed.
~\WindowsApplication1\mtI1.vb 34 21 MotoTally
and the function is :
VB.NET:
Public Function GetFileName(ByVal flname As String) As String
'Get the filename without the path or extension.
'Input Values:
' flname - path and filename of file.
'Return Value:
' GetFileName - name of file without the extension.
Dim posn As Integer, i As Integer
Dim fName As String
posn = 0
'find the position of the last "\" character in filename
For i = 1 To Len(flname)
If (Mid(flname, i, 1) = "\") Then posn = i
Next i
'get filename without path
fName = [U][COLOR="Navy"]Right[/COLOR][/U](flname, Len(flname) - posn)
'get filename without extension
posn = InStr(fName, ".")
If posn <> 0 Then
fName = [U][COLOR="Navy"]Left[/COLOR][/U](fName, posn - 1)
End If
GetFileName = fName
End Function
I am using VS 2008 and VB.Net and building a Windows Forms application to search a specific directory and harvest data from excel files generated by a new machine on the production line... and help would be greatly appreciated.
thanks