is there a way to retrieve text value from a listbox based on index ?
like if i enter index 0 and want to retrieve it's text value from the listbox
Printable View
is there a way to retrieve text value from a listbox based on index ?
like if i enter index 0 and want to retrieve it's text value from the listbox
Access the Items collection, i.e:
vb.net Code:
Dim value As String = Me.ListBox1.Items(0).ToString()
thanks alot
one more question if you please
if i have many items in my listbox and in some of them ther's symbol (%u) and i want to replase it with certain text but the items index could change any time
how to do this?
vb.net Code:
Public Class Form1 Protected Overrides Sub OnLoad(ByVal e As System.EventArgs) MyBase.OnLoad(e) Me.ReplaceListBoxText(Me.ListBox1, "u%", String.Empty) End Sub Public Sub ReplaceListBoxText(ByVal lb As ListBox, _ ByVal find As String, _ ByVal replacement As String) '//loops all items For index = 0 To lb.Items.Count - 1 lb.Items(index) = lb.Items(index).ToString() _ .Replace(find, replacement) Next End Sub End Class
i make it that way
vb Code:
dim i as integer = answer.indexof("any word") Dim sshort As String = answer.Items(i).ToString Dim suser As String = Replace(sshort, "%u", sNic)
i want to add to my listbox long string and i get this error
the field is too small to accept the amount of data you attempted to add. try to inserting or pasting less data
how can i make my list box accept long string item