' Collection of code snippets by Arne Vajhøj 
' (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
Imports System
Imports System.Collections.Specialized

Class MainClass

    Public Shared Function Parse(ByVal s As String) As NameValueCollection
        Dim res As NameValueCollection = New NameValueCollection
        Dim s2 As String = s.Split("?".ToCharArray)(1)
        Dim parts As String() = s2.Split("=&".ToCharArray)
        Dim i As Integer
        For i = 0 To (parts.Length / 2 - 1)
            res.Add(parts(2 * i), parts(2 * i + 1))
        Next
        Return res
    End Function

    Public Shared Sub Main(ByVal args As String())
        Dim col As NameValueCollection = Parse("http://minserver.dk/test.asp?var1=hej&var2=du")
        Dim i As Integer
        For i = 0 To (col.Count - 1)
            Console.WriteLine(col.GetKey(i) + " = " + col.GetValues(i)(0))
        Next
    End Sub
End Class 
