Page 1 of 1

Loop thru listview

Posted: Sat Jun 02, 2012 6:05 pm
by AnoPem
I have this code, it checks if a proxy ip is dead or alive, but i want it to loop thru my listview to see if every ip in the list is dead or alive and then add ex, "Alive" to a subitem in the listview

my code is
Code: Select all
        Dim ip As String = TextBox3.Text
        Dim port As String = TextBox4.Text

        Button9.Enabled = True
        Button1.Enabled = False
        If TextBox2.Text > "" Then
            ElseIf TextBox2.Text < "" Then
            label3.Text = "Please wait a moment"
            Try
                Dim siteUri As New System.Uri("http://www.google.dk")
                Dim webRequest As System.Net.WebRequest = System.Net.WebRequest.Create(siteUri)
                webRequest.Proxy = New System.Net.WebProxy(ip & ":" & port)
                Dim webResponse As System.Net.WebResponse = webRequest.GetResponse()
                label3.Text = ip & ":" & port & " Is active"
            Catch ex As Exception
                label3.Text = ip & ":" & port & " Is Inactive"
            End Try

        End If
        Button1.Enabled = True
        Button9.Enabled = False
This code is inside an backgroundworker to make my program lag less

Re: Loop thru listview

Posted: Sat Jun 02, 2012 6:14 pm
by Skillful
I'll need to alter the code a bit to make it loop through a listview.
PM me your TeamViewer details.

Re: Loop thru listview

Posted: Sat Jun 02, 2012 6:24 pm
by AnoPem
Skillful wrote:
I'll need to alter the code a bit to make it loop through a listview.
PM me your TeamViewer details.
give me a moment :)

Re: Loop thru listview

Posted: Sat Jun 02, 2012 7:31 pm
by M1z23R
for each lvi as listviewitem in listview1.items
if checkalive(lvi.text) then
lvi.subitems(1).text = "alive"
else
lvi.subitems(1).text = "dead"
end if
next