- Public Class Form1
-
Private Numbers(2,10) As Integer
-
Private number As Integer
-
Private UpperBound As Integer
-
-
Private Sub btnDisplay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisplay.Click
-
Dim sr As IO.StreamReader = IO.File.OpenText("Num.txt")
-
-
For i As Integer = 0 To 19 'before there were 21 loops for 20 lines?
-
number = CInt(sr.ReadLine)
-
If Numbers(0,CInt(number)) =0 then
-
Numbers(1,CInt(number))=i
-
End if
-
Numbers(0,CInt(number)) += 1
-
Next
-
sr.Close()
-
-
End Sub
-
I altered your code a bit...the second dimension I added to your array indicates the number of the line in your txt file at which some number starts appearing.
Sorting the array out by this dimension you get the order of each number's appearance in the list. You will lose the numbers though since your numbers are apparently indices of Numbers() at the same time and sorting by the second dimension is about reindexing. You will probably need another dimension to keep the actual values independently.