Dear visitor, welcome to Jabaco - Community.
If this is your first visit here, please read the Help. It explains in detail how this page works.
To use all features of this page, you should consider registering.
Please use the registration form, to register here or read more information about the registration process.
If you are already registered, please login here.
trimming a path to file name from a listbox
Hi,
I'm attempting to trim off the path of a file in a listbox so that I just end up with the file name. In vb I can use
Dim k As Long
k = InStrRev(lstPlaylist.List(lstPlaylist.ListIndex),"\")
If k > 0 Then lblTitle.Caption = right$(lstPlaylist.List(lstPlaylist.ListIndex), k)
This works but does not return everything to the right of the last \. It chops off some of the filename.
Is there a different way to do this in Jabaco?
Neil
Well, I think you have to use Mid() rather than Right() to extract all characters starting at a given position.
Look at this:
|
Jabaco Source
|
1
2
3
4
5
6
7
|
Dim k As Long
Dim s As String = "a very long name\with a middle part\here comes the rest"
k = InStrRev(s,"")
If k > 0 Then s = Mid(s, k + 1)
MsgBox s & " (k=" & k & ")"
|
Cheers
A1880
Thanks. To many years away from VB programming.
This worked:
Dim k As Long
Dim s As String = lstPlaylist.List(lstPlaylist.ListIndex)
k = InStrRev(s,"\")
If k > 0 Then s = Mid(s, k + 1)
lblTitle.Caption = s