Visual Basic.NET - Type Structure y matrices en VB.net

 
Vista:

Type Structure y matrices en VB.net

Publicado por Minotaure (1 intervención) el 22/12/2010 20:07:59
Estoy pasando un código de VB 6 a VB.net y tengo un problema al pasar un Type a una Structure.

El código en VB6 es el siguiente:
Const nodeCount As Integer = 9 'number of nodes - 1
Type DijkArestes
weight As Integer 'distance from vertices that it is connected to
destination As Integer 'name of vertice that it is connected to
End Type

Type Vertex
connections(nodeCount) As DijkArestes 'hold information above for each connection
numConnect As Integer 'number of connections - 1
distance As Integer 'distance from all other vertices
isDead As Boolean 'distance calculated
name As Integer 'name of vertice
End Type

Si en VB.net convierto los types a structure me da el siguiente erro la líniea del connections(nodeCount) As DijkArestes :
"Las matrices declaradas como miembros de estructura no se pueden declarar con un tamaño inicial."

En la documentación he leído tendría que declarar cómo tamaño dinámico y después cambiar la dimensión ReDim per me da error.

El código en VB.net es el siguiente:
Dim nodeCount As Integer 'number of nodes - 1 'S'han d'indicar el nombre de nodes del mapa -1
Public Structure DijkArestes
Public weight As Integer 'distance from vertices that it is connected to
Public estination As Integer 'name of vertice that it is connected to
End Structure

Public Structure Vertex
Public connections(nodeCount) As DijkArestes 'hold information above for each connection
Public numConnect As Integer 'number of connections - 1
Public distance As Integer 'distance from all other vertices
Public isDead As Boolean 'distance calculated
Public name As Integer 'name of vertice
End Structure

Private Sub Command1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalcularRuta.Click

[...]

nodeCount = 9 'Aquí s'haurien d'assignar el nombre de nodes reals -1

Const infinity As Integer = 15000 'number that is larger than max distance
Dim i As Integer 'loop counter
Dim j As Integer 'loop counter
Dim sourceP As Integer 'point to determine distance to from all nodes
Dim inputData As String 'temp variable to ensure good data enterred
Dim graph(nodeCount) As Vertex 'all inforamtion for each point (see Vertex declaration above)
Dim nextP As Integer 'closest point that is not dead
Dim min As Integer 'distance of closest point not dead
Dim outString As String 'string to display the output
Dim goodSource As Boolean

ReDim graph.connections(nodeCount)
[...]

End Sub

Concretamente me dice "'connections' no es un miembro de 'System.Array'."

Mi pregunta es, ¿¿en VB.net como puedo indicar el tamaño de la matriz connections??

Muchas gracias de antemano.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder