Hey Guys,

Any help on this would be greatly appreciated.

So I've got a list of strings in ListBox1 and I want to remove the last seven characters from each string in the list and write the output to an excel file...

Any tips would be greatly appreciated.

Thanks in advance

Here is the code:

Dim result As String
result = beginingString.Text.Remove(beginingString.Text.Length - 7, 7)

Sorry mate, that reply didn't help too much at all (Beginning was spelt wrong and I don't even think that's a vb function anyway...)

I'm after code that will loop through each item in the listbox and remove the last 7 characters from each item and save the output to an excel file...

cheers guys :)

Dim tempList As New List(Of String) '// create temp list.
        For Each itm As String In ListBox1.Items '// loop thru listbox.
            If itm.Length > 7 Then '// to not get errors, check if item's length is greater than 7.
                tempList.Add(itm.Substring(0, 7)) '// if greater than 7, get the substring.
            Else
                tempList.Add(itm) '// if less than 7, add item as is.
            End If
        Next
        ListBox1.Items.Clear()
        ListBox1.DataSource = tempList '// add items back to the listbox.
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.