如何调用最短路径函数
如何调用这个函数啊?Public Function shortpath(startno As Integer, endno As Integer) As Single
Dim result() As Single
Dim result1 As Integer
Dim s1 As Single
Dim min As Single
Dim ii, i, j, aa As Integer
Dim yc() As Boolean
Dim ycd() As Boolean
Dim rs1() As Single
Dim no() As Integer
Dim nopoint As Integer
ReDim yc(1 To maxno) As Boolean
ReDim ycd(1 To maxno) As Boolean
ReDim rs1(1 To maxno) As Single
ReDim result(1 To 2, 1 To maxno) As Single
For i = 1 To maxno
yc(i) = False
ycd(i) = False
rs1(i) = 1E+38
Next i
ll = startno
yc(ll) = True
j = 0
For aa = 1 To maxno
For i = 1 To indexa1(2, ll)
result1 = b1(indexa1(1, ll) - i + 1)
s1 = c1(indexa1(1, ll) - i + 1) + result(2, ll)
If yc(result1) = True Then GoTo 200
If ycd(result1) = True Then
If rs1(result1) >= s1 Then
rs1(result1) = s1
result(1, result1) = ll
result(2, result1) = s1
GoTo 200
Else
GoTo 200
End If
End If
ycd(result1) = True
rs1(result1) = s1
result(1, result1) = ll
result(2, result1) = s1
j = j + 1
ReDim Preserve no(1 To j) As Integer
no(j) = result1
200 Next i
For i = 1 To indexb2(2, ll)
result1 = a2(indexb2(1, ll) - i + 1)
s1 = c2(indexb2(1, ll) - i + 1) + result(2, ll)
If yc(result1) = True Then GoTo 300
If ycd(result1) = True Then
If rs1(result1) >= s1 Then
rs1(result1) = s1
result(1, result1) = ll
result(2, result1) = s1
GoTo 300
Else
GoTo 300
End If
End If
ycd(result1) = True
rs1(result1) = s1
result(1, result1) = ll
result(2, result1) = s1
j = j + 1
ReDim Preserve no(1 To j) As Integer
no(j) = result1
300 Next i
min = 1E+38
minpoint = Null
For i = aa To j
If min > rs1(no(i)) Then
ii = i
min = rs1(no(i))
minpoint = no(i)
End If
Next i
If min = 1E+38 Then Exit Function
no(ii) = no(aa)
no(aa) = minpoint
yc(minpoint) = True
ll = minpoint
If minpoint = endno Then Exit For
Next aa
Stpath = result(2, endno)
End Function