主题:求帮助!
Private Structure genotype
Public gene() As Double
Public fitness As Double
Public upper() As Double
Public lower() As Double
Public rfitness As Double
Public cfitness As Double
End Structure
Private Sub initialize()
Dim i, j As Integer
Dim lbound, ubound As Double
Dim randval As New Random
For i = 0 To 3
For j = 0 To 50
genotype(j).fitness = 0
genotype(j).rfitness = 0
genotype(j).cfitness = 0
genotype(j).lower(i) = lbound
genotype(j).upper(i) = ubound
genotype(j).gene(i) = randval.Next(genotype(j).lower(i), genotype(j).upper(i))
Next
Next
End Sub
我先定义"genotype"为结构体变量,然后在下面在调用它,这样为什么是错误的?
Public gene() As Double
Public fitness As Double
Public upper() As Double
Public lower() As Double
Public rfitness As Double
Public cfitness As Double
End Structure
Private Sub initialize()
Dim i, j As Integer
Dim lbound, ubound As Double
Dim randval As New Random
For i = 0 To 3
For j = 0 To 50
genotype(j).fitness = 0
genotype(j).rfitness = 0
genotype(j).cfitness = 0
genotype(j).lower(i) = lbound
genotype(j).upper(i) = ubound
genotype(j).gene(i) = randval.Next(genotype(j).lower(i), genotype(j).upper(i))
Next
Next
End Sub
我先定义"genotype"为结构体变量,然后在下面在调用它,这样为什么是错误的?