|
-
Sep 7th, 2010, 12:04 PM
#1
Thread Starter
Fanatic Member
listbox Help
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
-
Sep 7th, 2010, 12:06 PM
#2
Re: listbox Help
Access the Items collection, i.e:
vb.net Code:
Dim value As String = Me.ListBox1.Items(0).ToString()
-
Sep 7th, 2010, 12:18 PM
#3
Thread Starter
Fanatic Member
Re: listbox Help
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?
-
Sep 7th, 2010, 12:27 PM
#4
Re: listbox Help
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
-
Sep 7th, 2010, 12:41 PM
#5
Thread Starter
Fanatic Member
Re: listbox Help
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)
-
Sep 7th, 2010, 01:03 PM
#6
Thread Starter
Fanatic Member
Re: listbox Help
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|