I am attempting to sort a file which consists of a list of strings which contain two numerical variables stored per line of text. The variables are stored in the following format "0000" and they take the form of a basic x,y coordinate in a 32*40 grid.
The two numeric variables can range in value from 101 to 3240. I came up with the following routine, but it is very inefficient:-
For f = 1 To 32
For g = 1 To 40
For h = 1 To 32
For i = 1 To 40
Open currentdirectory$ & "\TradeRoutes2.TMP" For Input As #1
Do Until EOF(1)
Line Input #1, lineoftext$
If Format(f, "00"
& Format(g, "00"
= Mid$(lineoftext$, 1, 4) And Format(h, "00"
& Format(i, "00"
= Mid$(lineoftext$, 8, 4) Then
traderoutelist$ = traderoutelist$ & lineoftext$ & NL
Exit Do
End If
Loop
DoEvents
Label2.Caption = f & " " & g & " " & h & " " & i
Close #1
Next i
Next h
Next g
Next f
Can anyone come up with a suggestion for a better and more efficient routine? [sig][/sig]
The two numeric variables can range in value from 101 to 3240. I came up with the following routine, but it is very inefficient:-
For f = 1 To 32
For g = 1 To 40
For h = 1 To 32
For i = 1 To 40
Open currentdirectory$ & "\TradeRoutes2.TMP" For Input As #1
Do Until EOF(1)
Line Input #1, lineoftext$
If Format(f, "00"
traderoutelist$ = traderoutelist$ & lineoftext$ & NL
Exit Do
End If
Loop
DoEvents
Label2.Caption = f & " " & g & " " & h & " " & i
Close #1
Next i
Next h
Next g
Next f
Can anyone come up with a suggestion for a better and more efficient routine? [sig][/sig]