i know i always post problems with listboxes but...
i am generating a listbox from a txt file this list box has ip's in and what im trying to do is run a for each statement
for each item in listbox.items me.query() next
this is what the query() is
Try Dim UdpClient As New UdpClient() UdpClient.Connect("my ip in here", 2005) ' Sends a message to the host to which you have connected. Dim sendBytes As [Byte]() = Encoding.ASCII.GetBytes(8124) UdpClient.Send(sendBytes, sendBytes.Length) Dim udpClientB As New UdpClient() udpClientB.Send(sendBytes, sendBytes.Length, "my ip in here", 2005) Dim RemoteIpEndPoint As New IPEndPoint(IPAddress.Any, 0) Dim receiveBytes As [Byte]() = UdpClient.Receive(RemoteIpEndPoint) Dim returnData As String = Encoding.ASCII.GetString(receiveBytes) Dim sname As String Dim Track As String Dim real As String Dim raceLen As String Dim musers As String musers = returnData.Substring(16, 4) musers = byte4toint(musers) Dim users As String users = returnData.Substring(208, 4) users = byte4toint(users) sname = returnData.ToCharArray(20, 14) Track = returnData.ToCharArray(72, 14) real = returnData.ToCharArray(86, 10) raceLen = returnData.ToCharArray(111, 8) ListBox1.Items.Add(sname + " | " + Track + " | " + real + " | " + raceLen + " | " + musers + " - " + users) Catch MsgBox("error") End Try
so i would like to query every ip thats in the list box to show the racing community what race servers are open
im populating the list box by...
Try Dim file_name As String = ipdata() Dim stream_reader As New IO.StreamReader(file_name) Dim line As String = stream_reader.ReadLine() ' Read the file one line at a time. ' Alternatively you could grab it ' all, use Split, and the loop through ' the lines in an array. ' line = stream_reader.ReadLine() Do While Not (line Is Nothing) ' Trim and make sure the line isn't blank. line = line.Trim() If line.Length > 0 Then ips.Items.Add(line) ' Get the next line. line = stream_reader.ReadLine() Loop ips.SelectedIndex = 0 stream_reader.Close() Catch exc As Exception ' Report all errors. MsgBox(exc.Message, MsgBoxStyle.Exclamation, "Read Error") End Try
this is the same code i used for my last app to populate a list box
Thanks for your time reading this
This post has been edited by TADS: 17 February 2009 - 04:50 PM