HI
Basically, I have a 20 x 20 array which contains the distances between 20 cities. I need to find the closest city beginning at the starting city.
Whilst I've a programmed the minimum, I am not sure how to exclude cities that have already been visited as you cannot use these again.
My code so far is as follows:
StartCity = Me.ComboBox1.Value
SolutionArray(1) = City(StartCity)
SolutionArray(21) = City(StartCity)
MinDist = 1000
i = 2
For i = 2 To 20
For j = 1 To 20
If DistArrayTwo(StartCity, j) < MinDist And j <> StartCity Then
MinDist = DistArrayTwo(StartCity, j)
SolutionArray(i) = City(j)
End If
Next j
StartCity = SolutionArray(i)
MinDist = 1000
Next i
PLEASE HELP!
Basically, I have a 20 x 20 array which contains the distances between 20 cities. I need to find the closest city beginning at the starting city.
Whilst I've a programmed the minimum, I am not sure how to exclude cities that have already been visited as you cannot use these again.
My code so far is as follows:
StartCity = Me.ComboBox1.Value
SolutionArray(1) = City(StartCity)
SolutionArray(21) = City(StartCity)
MinDist = 1000
i = 2
For i = 2 To 20
For j = 1 To 20
If DistArrayTwo(StartCity, j) < MinDist And j <> StartCity Then
MinDist = DistArrayTwo(StartCity, j)
SolutionArray(i) = City(j)
End If
Next j
StartCity = SolutionArray(i)
MinDist = 1000
Next i
PLEASE HELP!