Hey guys i tried getting CodeOrder snippet working but it really messup all my tables and such when i try to add for other groups sorting first 3 works fine but when i try to add more everything gets strange :S

so if you can fix it ??
Here are my snippets:
Form1.vb
http://pastebin.com/N2M0N4in
Form1.Designer.vb
http://pastebin.com/HSnTjdXz

Please if some one can help me? :/

I think the "CheckForIllegalCrossThreadCalls = False" causes the strange things happens.
Definition of CheckForIllegalCrossThreadCalls:

Gets or sets a value indicating whether to catch calls on the wrong thread that access a control's Handle property
When a thread other than the creating thread of a control tries to access one of that control's methods or properties, it often leads to unpredictable results. A common invalid thread activity is a call on the wrong thread that accesses the control's Handle property.

It does not :S If i delete it or change it other part of code wont work :S So guys do you have any idea?

Of course your code won't work if you delete the CheckForIllegalCrossThreadCalls = False.
That already should give you something to think...
Setting the CheckForIllegalCrossThreadCalls means, "try get the value from control, if invoke is required, just do nothing and keep going". That way you might get SOME results but not the one you expect.

So what you should do is using delegates to receive the values of your controls.

commented: "quotes.expain it quite well", Return ".thanx." :) +12

.thanx for p.m. w/link to thread; will try to figure out a better way to sort.items and reply; though in the mean.while, I hope that others will try to provide possible solutions since those always seem to help for such threads as this.:)

Okay thank you cody :) Im waiting for you :)

@codeorder, if im allowed i would suggest creating a class for each proxy, adding them to a list(of proxy) and sort it then based on the particular property.
But thats just a suggestion.

>>@codeorder, if im allowed i would suggest...
.suggest as you may, I'm still trying to crack this s.o.b. out; tough cookie though.:)
Do post a sample.code that might help to a better solution. Return "thanx" .

Ok, I had some spare time this morning, so I did some modifications on the code:
1. Created a class "Proxy"

Public Class Proxy

	Public Property IPAddress() As string
	Public Property Port() As integer
	Public Property Country() As string
	Public Property Speed() As integer
	Public Property Time() As integer
	Public Property [Type]() As string
	Public Property Anonymity() As string

End Class

2. Removed the crossthreadcall check (coz i don't like it:), added some custom comparer to sort the proxies. Complete Form1 code behind:

Imports System.Text.RegularExpressions

Public Class Form1

	Dim Proxies As New List(Of Proxy)
	Dim CurrentSortDirection As Boolean

	Private Event ClearProxies()

	Private Sub GrabProxies()

		Dim i As Integer = 1

		Do Until i = NumericUpDown1.Value + 1
			Dim request As System.Net.HttpWebRequest = CType(System.Net.HttpWebRequest.Create("http://hidemyass.com/proxy-list/" + i.ToString), Net.HttpWebRequest)
			Dim response As System.Net.HttpWebResponse = CType(request.GetResponse, Net.HttpWebResponse)

			Dim sr As System.IO.StreamReader = New System.IO.StreamReader(response.GetResponseStream())

			Dim rssourcecode As String = sr.ReadToEnd

			Dim r As New System.Text.RegularExpressions.Regex("(?<IP>\d{1,4}\.\d{1,4}\.\d{1,4}\.\d{1,4})</span></td>\D+(?<Port>\d{1,5})</td>\D+<img src=""\S+""\D+""flag"" /> (?<Country>\w+)\D+\S+\D+(?<Speed>\d+)%\D+\S+\D+(?<Time>\d+)%""\D+<td>(?<Type>\w+)\D+"">(?<Anonym>\w+)")
			Dim matches As MatchCollection = r.Matches(rssourcecode)


			For Each itemcode As Match In matches
				Dim prox As New Proxy With {.IPAddress = itemcode.Groups("IP").Value,
				 .Port = CInt(itemcode.Groups("Port").Value),
				 .Country = itemcode.Groups("Country").Value,
				 .Speed = CInt(itemcode.Groups("Speed").Value),
				 .Time = CInt(itemcode.Groups("Time").Value),
				 .Type = itemcode.Groups("Type").Value,
				 .Anonymity = itemcode.Groups("Anonym").Value}
				Proxies.Add(prox)
                                'instead of crossthreadcallcheck invoke the operation
				Me.Invoke(Sub()
							  AddProxy(prox)
						  End Sub)
			Next
			i = i + 1
		Loop

	End Sub

	Private Sub AddProxy(proxy As Proxy)
		With ListView1.Items.Add("")
			.SubItems.Add(proxy.IPAddress)
			.SubItems.Add(proxy.Port.ToString)
			.SubItems.Add(proxy.Country)
			.SubItems.Add(proxy.Speed & "%")
			.SubItems.Add(proxy.Time & "%")
			.SubItems.Add(proxy.Type)
			.SubItems.Add(proxy.Anonymity)
		End With
	End Sub

	Private Sub AssignDatasource()
		For Each proxy In Proxies
			AddProxy(proxy)
		Next
	End Sub

	Private Sub Form1_ClearProxies() Handles Me.ClearProxies
		Proxies.Clear()
		ListView1.Items.Clear()
	End Sub

	Private Sub ListView1_ColumnClick(ByVal sender As Object, ByVal e As System.Windows.Forms.ColumnClickEventArgs) Handles ListView1.ColumnClick

		If ListView1.Items.Count = 0 Then Return

		'clear listview
		ListView1.Items.Clear()

		Select Case e.Column
			Case 1
				Proxies.Sort(New IPAddressComparer)
			Case 2
				Proxies.Sort(New PortComparer)
			Case 3
				Proxies.Sort(New CountryComparer)
			Case 4
				Proxies.Sort(New SpeedComparer)
			Case 5
				Proxies.Sort(New TimeComparer)
			Case 6
				Proxies.Sort(New TypeComparer)
			Case 7
				Proxies.Sort(New AnonymityComparer)
		End Select


		If CurrentSortDirection Then
			Proxies.Reverse()
		End If

		CurrentSortDirection = Not CurrentSortDirection
		AssignDatasource()

	End Sub

	Private Sub SaveFileDialog1_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles SaveFileDialog1.FileOk

		Dim myFile As String = SaveFileDialog1.FileName
		Dim myWriter As New IO.StreamWriter(myFile)

		For Each proxy As Proxy In Proxies
			If CheckBox1.Checked Then
				myWriter.WriteLine("{0}:{1}", proxy.IPAddress, proxy.Port)
			Else
				With proxy
					myWriter.WriteLine("{0} | {1} | {2} | {3}% | {4}% | {5} | {6} ", .IPAddress, .Port, .Country, .Speed, .Time, .Type, .Anonymity)
				End With
			End If
		Next
		myWriter.Flush()
		
		myWriter.Close()
	End Sub

	Private Sub StartButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
		RaiseEvent ClearProxies()
		Dim Thread1 As New System.Threading.Thread(AddressOf GrabProxies)
		Thread1.Start()
	End Sub

	Private Sub ExportButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
		If Proxies.Count = 0 Then
			Return
		End If
		SaveFileDialog1.ShowDialog()
	End Sub

	Private Sub ClearButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
		RaiseEvent ClearProxies()
	End Sub

#Region "Nested Classes Comparers"

	Private Class IPAddressComparer
		Implements IComparer(Of Proxy)


		Public Function Compare(ByVal first As Proxy, ByVal second As Proxy) As Integer Implements System.Collections.Generic.IComparer(Of Proxy).Compare
			Return IPAddressToLongBackwards(first.IPAddress).CompareTo(IPAddressToLongBackwards(second.IPAddress))
		End Function

		Private Function IPAddressToLongBackwards(ByVal IPAddr As String) As UInteger
			Dim oIP As System.Net.IPAddress = System.Net.IPAddress.Parse(IPAddr)
			Dim byteIP() As Byte = oIP.GetAddressBytes()

			Dim ip As UInteger = CUInt(byteIP(0)) << 24
			ip += CUInt(byteIP(1)) << 16
			ip += CUInt(byteIP(2)) << 8
			ip += CUInt(byteIP(3))

			Return ip
		End Function

	End Class

	Private Class PortComparer
		Implements IComparer(Of Proxy)

		Public Function Compare(ByVal first As Proxy, ByVal second As Proxy) As Integer Implements System.Collections.Generic.IComparer(Of Proxy).Compare
			Return first.Port.CompareTo(second.Port)
		End Function

	End Class

	Private Class CountryComparer
		Implements IComparer(Of Proxy)

		Public Function Compare(ByVal first As Proxy, ByVal second As Proxy) As Integer Implements System.Collections.Generic.IComparer(Of Proxy).Compare
			Return first.Country.CompareTo(second.Country)
		End Function

	End Class

	Private Class SpeedComparer
		Implements IComparer(Of Proxy)

		Public Function Compare(ByVal first As Proxy, ByVal second As Proxy) As Integer Implements System.Collections.Generic.IComparer(Of Proxy).Compare
			Return first.Speed.CompareTo(second.Speed)
		End Function

	End Class

	Private Class TypeComparer
		Implements IComparer(Of Proxy)

		Public Function Compare(ByVal first As Proxy, ByVal second As Proxy) As Integer Implements System.Collections.Generic.IComparer(Of Proxy).Compare
			Return first.Type.CompareTo(second.Type)
		End Function

	End Class

	Private Class TimeComparer
		Implements IComparer(Of Proxy)

		Public Function Compare(ByVal first As Proxy, ByVal second As Proxy) As Integer Implements System.Collections.Generic.IComparer(Of Proxy).Compare
			Return first.Time.CompareTo(second.Time)
		End Function

	End Class

	Private Class AnonymityComparer
		Implements IComparer(Of Proxy)

		Public Function Compare(ByVal first As Proxy, ByVal second As Proxy) As Integer Implements System.Collections.Generic.IComparer(Of Proxy).Compare
			Return first.Anonymity.CompareTo(second.Anonymity)
		End Function

	End Class


#End Region

End Class

PS: I did NOT touch the designer. so all controls and their names remains as they were before.

If you have any questions...please ask ahead

commented: this.post, i can probably learn quite a bit.from:) .thanx. +12

Thank you it works like a charm :) I will be adding now some more functions :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.