Hi,
I have a listbox with lstPartnumber as it's name. It displays multiple number items with quotation marks as: "abc".
I want to remove these quotation marks from each item in the listbox. Which property should I use to remove these quotation marks from the text of each item.
Thank you!
Loading
Satyapriya NayakPosted Oct 28, 2011, 11:25 PM
Try this......
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
For i As Integer = 0 To ListBox1.Items.Count - 1
ListBox1.Items(i) = ListBox1.Items(i).Replace(Chr(34), "" & "")
Next i
End Sub
End Class
Thanks
If this post helps you mark it as answer
VulpesPosted Oct 14, 2011, 2:57 PM
Can you clarify what exactly is displayed in the ListBox?
If it's "abc" then this 'if' statement should be true:
If item.StartsWith("""") AndAlso item.EndsWith("""") Then
because the first and last characters of the string are double quote characters and because they need to be doubled when used in a VB string literal.
The following code definitely works as I've tried it myself to make absolutely sure:
End Class
latika singhPosted Oct 14, 2011, 1:50 PM
VulpesPosted Oct 14, 2011, 8:52 AM
latika singhPosted Oct 14, 2011, 8:43 AM
So with items = items.Substring(1, items.Length - 3) it takes out the double quotation but displays them as "abc" since it is stored as string.
VulpesPosted Oct 14, 2011, 4:33 AM