0
Public Class Population
Dim tours() As Tour ' Tour is a class and I have to make and object array
Public Sub New(ByVal populationSize As Integer, ByVal initialise As Boolean)
Dim tours As New Tour(populationSize) '
If initialise Then
' Loop and create individuals
For i As Integer = 0 To (populationSize - 1)
Dim newTour As New Tour()
newTour.generateIndividual()
saveTour(i, newTour)
Next i
End If
End Sub
Public Sub saveTour(ByVal index As Integer, ByVal tour As Tour)
tours(index) = tour ' getting error in this line
End Sub
在Java
相同的代码是this link未将对象引用设置为对象的实例。 Visual Basic中的VB
请注意,您的数组的大小将是族群大小+ 1,因为在VB中的数组声明传递的值是上限,不尺寸。 – 2013-02-25 16:30:48