Here’s a simple example:
Dim R As New Random
Dim Count As Integer
Dim RangeLength As Integer
Dim DataFileName As String = System.IO.Path.Combine(My.Computer.FileSystem.SpecialDirectories.MyDocuments, "test.txt")
Dim Links As New List(Of List(Of String))
Using SR As New System.IO.StreamReader(DataFileName)
While Not SR.EndOfStream
Count = 0
RangeLength = R.Next(2, 6)
Dim curLinkSet As New List(Of String)
Links.Add(curLinkSet)
While Not SR.EndOfStream AndAlso Count < RangeLength
curLinkSet.Add(SR.ReadLine)
Count = Count + 1
End While
End While
End Using
For i As Integer = 0 To Links.Count - 1
Debug.Print("Set #" & i)
Dim LinkSet As List(Of String) = Links(i)
For x As Integer = 0 To LinkSet.Count - 1
Debug.Print(x & ": " & LinkSet(x))
Next
Debug.Print("")
Next
Sample output:
Set #0
0: aa
1: bb
2: cc
Set #1
0: dd
1: ee
2: ff
3: gg
4: hh
Set #2
0: ii
1: yy
2: tt
3: rr
Set #3
0: ee
1: ww
2: qq
3: uu
Set #4
0: oo
1: pp
4
solved vb.net reading text file ,split to random range