I'm working on this project where I have IP addresses in a listbox. I've already gotten a method that transfers the listbox items into the textbox , but I need the IPs to change themselves with a button.
For example , I have these three IP addresses :
123.456.78
891.23.45.6
789.123.12
The current IP address in the textbox is 123.456.78 but when I click a button it changes too line two which is 891.23.45.6 and it can ONLY be that in the textbox (not like 123.456.78 is pushed off to the side).
Can someone help me out? I would really appreciated it.
Listbox Line Going One By One In Textbox.
Page 1 of 18 Replies - 294 Views - Last Post: 06 October 2012 - 08:10 AM
Replies To: Listbox Line Going One By One In Textbox.
#2
Re: Listbox Line Going One By One In Textbox.
Posted 06 October 2012 - 06:11 AM
Can we see the line where you're putting the item from the listbox into the textbox. It sounds like you're performing a concatenation. If you set the text property = something that is what the text property holds. If you are concatenating the text property, it will add to what is there.
Let's see where you're setting the text property of the textbox.
Let's see where you're setting the text property of the textbox.
#3
Re: Listbox Line Going One By One In Textbox.
Posted 06 October 2012 - 06:30 AM
CharlieMay, on 06 October 2012 - 06:11 AM, said:
Can we see the line where you're putting the item from the listbox into the textbox. It sounds like you're performing a concatenation. If you set the text property = something that is what the text property holds. If you are concatenating the text property, it will add to what is there.
Let's see where you're setting the text property of the textbox.
Let's see where you're setting the text property of the textbox.
Ok , well this is all in one button.
'*Grabbing our proxy text from our online server (this way we can keep updating our proxies).
Dim Str As System.IO.Stream
Dim srRead As System.IO.StreamReader
Try
' make a Web request
Dim req As System.Net.WebRequest = System.Net.WebRequest.Create("https://dl.dropbox.com/u/100659925/ProxiesPortAlways8080.txt")
Dim resp As System.Net.WebResponse = req.GetResponse
Str = resp.GetResponseStream
srRead = New System.IO.StreamReader(Str)
' read all the text
TextBox2.Text = srRead.ReadToEnd
Catch ex As Exception
TextBox2.Text = "Unable to download content"
Finally
' Close Stream and StreamReader when done
srRead.Close()
Str.Close()
End Try
' Assign string to reference.
Dim value1 As String = TextBox2.Text
' Replace word with another word.
Dim value2 As String = value1.Replace("<br>", vbNewLine)
TextBox2.Text = value2
ListBox1.Items.Add(TextBox2.Text)
'*Now , we're taking our fresh proxies in the textbox and moving them into our listbox.
ListBox1.Items.AddRange(TextBox2.Text.Split(vbNewLine))
#4
Re: Listbox Line Going One By One In Textbox.
Posted 06 October 2012 - 06:36 AM
OK, so where is the code where you're putting the selecteditem of the listbox into the textbox as you described above?
Also, why do you need it to go to a textbox? are you going to use the contents of that textbox in something? If you need the textbox to be what is hilighted in the listbox, why not just use the selecteditem of the listbox to get that value to use in something.
Also, why do you need it to go to a textbox? are you going to use the contents of that textbox in something? If you need the textbox to be what is hilighted in the listbox, why not just use the selecteditem of the listbox to get that value to use in something.
This post has been edited by CharlieMay: 06 October 2012 - 06:39 AM
#5
Re: Listbox Line Going One By One In Textbox.
Posted 06 October 2012 - 06:46 AM
CharlieMay, on 06 October 2012 - 06:36 AM, said:
OK, so where is the code where you're putting the selecteditem of the listbox into the textbox as you described above?
Also, why do you need it to go to a textbox? are you going to use the contents of that textbox in something? If you need the textbox to be what is hilighted in the listbox, why not just use the selecteditem of the listbox to get that value to use in something.
Also, why do you need it to go to a textbox? are you going to use the contents of that textbox in something? If you need the textbox to be what is hilighted in the listbox, why not just use the selecteditem of the listbox to get that value to use in something.
Oh , I left that part out. And yes I will be using the textbox for something , I need each IP to be switched with a timer in the textbox through the value of the listbox. I just need the listbox to be able to update my IPs.
#6
Re: Listbox Line Going One By One In Textbox.
Posted 06 October 2012 - 07:14 AM
Nasss, on 06 October 2012 - 09:46 AM, said:
Oh , I left that part out.
So can you supply it?
Look what I'm saying is: Let's say you have the following in your listbox
- 123.456.789.012
123.456.789.013
321.654.987.111
Now lets suppose you clicked on the first item of the listbox
You can set the textbox1.text = listbox1.selecteditem
now textbox1.text holds the SAME thing that is selected in listbox1 (because you filled in with a list of strings)
Now lets say you want to use that value
Messagebox.Show("My Textbox Shows:" & TextBox1.Text)
would result in a messagebox that reads: My Textbox Shows: 123.456.789.012
But, let's decide that we didn't use the textbox but instead used the selecteditem of the listbox
Messagebox.Show("I selected in my list: " & ListBox1.SelectedItem
would result in a messagebox that reads: I selected in my list: 123.456.789.012
As you can see both results are the same because all you did in the textbox was copy a string of a selected item to a string in a textbox to use as a string in something else.
All I'm pointing out is you're just using two different ways of displaying a string to get a string when you could have just taken it straight from the source. (in this case the ListBox)
This post has been edited by CharlieMay: 06 October 2012 - 07:15 AM
#7
Re: Listbox Line Going One By One In Textbox.
Posted 06 October 2012 - 07:54 AM
CharlieMay, on 06 October 2012 - 07:14 AM, said:
Nasss, on 06 October 2012 - 09:46 AM, said:
Oh , I left that part out.
So can you supply it?
Look what I'm saying is: Let's say you have the following in your listbox
- 123.456.789.012
123.456.789.013
321.654.987.111
Now lets suppose you clicked on the first item of the listbox
You can set the textbox1.text = listbox1.selecteditem
now textbox1.text holds the SAME thing that is selected in listbox1 (because you filled in with a list of strings)
Now lets say you want to use that value
Messagebox.Show("My Textbox Shows:" & TextBox1.Text)
would result in a messagebox that reads: My Textbox Shows: 123.456.789.012
But, let's decide that we didn't use the textbox but instead used the selecteditem of the listbox
Messagebox.Show("I selected in my list: " & ListBox1.SelectedItem
would result in a messagebox that reads: I selected in my list: 123.456.789.012
As you can see both results are the same because all you did in the textbox was copy a string of a selected item to a string in a textbox to use as a string in something else.
All I'm pointing out is you're just using two different ways of displaying a string to get a string when you could have just taken it straight from the source. (in this case the ListBox)
That all made perfect sense , but I wan't the listbox to switch to a new item after like every x.x.x seconds.
#8
Re: Listbox Line Going One By One In Textbox.
Posted 06 October 2012 - 08:09 AM
To switch to a new item after every seconds, use this code:
You can offcourse run that code inside a different thread. Or modify it to a infinite loop that sets index back to 0 when the current index is the last item
For i As Integer = 0 To ListBox1.Items.Count - 1 Step 1
ListBox1.SelectedIndex = i
Thread.Sleep(5000) ' Wait for 5 seconds
Next
You can offcourse run that code inside a different thread. Or modify it to a infinite loop that sets index back to 0 when the current index is the last item
#9
Re: Listbox Line Going One By One In Textbox.
Posted 06 October 2012 - 08:10 AM
dotINSolution, on 06 October 2012 - 08:09 AM, said:
To switch to a new item after every seconds, use this code:
You can offcourse run that code inside a different thread. Or modify it to a infinite loop that sets index back to 0 when the current index is the last item
For i As Integer = 0 To ListBox1.Items.Count - 1 Step 1
ListBox1.SelectedIndex = i
Thread.Sleep(5000) ' Wait for 5 seconds
Next
You can offcourse run that code inside a different thread. Or modify it to a infinite loop that sets index back to 0 when the current index is the last item
THANK YOU!!!!!!!!!!!!!!!!!!!!!!!!
+REP
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote




|