string formatting

  • Thread starter Thread starter Brian Cahill
  • Start date Start date
B

Brian Cahill

I am attempting to populate a listbox from a text file. I would like
my result to get everything after that last "/" character. This code
gets everything before.

Do While objReader.Peek() <> -1
TextLine = objReader.ReadLine()
TextLine = TextLine.Substring(0, TextLine.LastIndexOf("/"c))
MsgBox(TextLine)
Loop

Example:
Applications/AS - ED Tracking Board/EDTB Train

I would like it to result to this
EDTB Train

Instead I am getting this:
Applications/AS - ED Tracking Board

thanks
 
Do While objReader.Peek() <> -1
TextLine = objReader.ReadLine()
TextLine =
TextLine.Substring(TextLine.LastIndexOf("/"c),TextLine.lenght )
MsgBox(TextLine)
Loop
 
that gave me an error:

Index and length must refer to a location within the string.
Parameter name: length
 
TextLine = TextLine.Substring(TextLine.LastIndexOf("/"c))

Note that LastIndexOf returns -1 if it can't find the character (thus
causing the above code to throw an exception)

/claes
 
Back
Top