Removing Certain text from a Listbox Item

tonycrew

Well-known member
Joined
Apr 20, 2009
Messages
55
Programming Experience
Beginner
Hello, Im trying to remove a certain bit of text from my listbox item..

heres my code..

VB.NET:
If ListBox1.Text.Contains(".zip") Then
	ListBox1.Text = ListBox1.Text.Remove(".zip")
End If

and when i start it and it tries to remove it, it comes up with an error saying

VB.NET:
Conversion from string ".zip" to type 'Integer' is not valid.

ive tried, this code..

VB.NET:
If ListBox1.Text.Contains(".zip") Then
	ListBox1.Text.Remove(".zip")
End If
 
Assuming you care that the .zip is the file extension.

VB.NET:
		For i As Integer = 0 To Me.ListBox1.Items.Count - 1
			Dim fi As New IO.FileInfo(Me.ListBox1.Items(i))
			If fi.Extension = ".zip" Then
				Me.ListBox1.Items(i) = Me.ListBox1.Items(i).ToString.Replace(".zip", "")
			End If
		Next
 
Back
Top