Comment initialiser un tableau dans une structure

Je suis en train d'initialiser un tableau et d'attribuer des valeurs, mais j'ai des problèmes de

Public Structure test1
    <VBFixedArray(6)> Dim Id() As String
    Public Sub initialize()
        ReDim Id(6)
    End Sub
End Structure

Dim myvalues() as test1
...
ReDim myvalues(10)

Je suis en train d'accomplir ceci avec l'exemple suivant

For i as short = 0 to 10
    myvalues(i).Id(1) = "V"
    myvalues(i).Id(2) = "H"
    ...
    myvalues(i).Id(6) = "J"
next i

Ce n'est pas de travail bien et je ne suis pas sûr de la bonne mise en œuvre?

EDIT:

Imports Microsoft.VisualBasic
Module Module1
Structure test1
<VBFixedArray(6)> Dim Id() As String
Public Sub initialize()
ReDim Id(6)
For im As Integer = 0 To 6
Id(im) = ""
Next im
End Sub
End Structure
Sub Main()
Dim i As Integer
Dim myvalues() As test1
ReDim myvalues(10)
For Each oTest As test1 In myvalues
' Initialize the structure 
ReDim myvalues(10)
oTest.initialize()
' Now loop through the array based on the bounds it was configured for
'initialize to empty string(NOT ABLE TO ASSIGN TO> myvalues(i).Id(j))
'I Get ERROR>>>Object reference not set to an instance of an object<<<<<
'For i = 0 To 10
For j As Integer = oTest.Id.GetLowerBound(0) To oTest.Id.GetUpperBound(0)
' Set the values in a case statement so that alterations to the size of the index won't break your code.
Select Case j
Case 0
oTest.Id(j) = "A"
myvalues(i).Id(j) = "A"
Case 1
oTest.Id(j) = "B"
'myvalues(i).Id(j) = "B"
Case 2
oTest.Id(j) = "C"
'myvalues(i).Id(j) = "C"
Case 3
oTest.Id(j) = "D"
'myvalues(i).Id(j) = "D"
Case 4
oTest.Id(j) = "E"
'myvalues(i).Id(j) = "E"
Case 5
oTest.Id(j) = "F"
'myvalues(i).Id(j) = "F"
Case 6
oTest.Id(j) = "G"
'myvalues(i).Id(j) = "G"
End Select
Next j
'Next i
Next 'oTest
'assign<<<<<<<<<<<<<<<<<<< NOT WORKING>>>>
'<<Id() is not set to <empty string> it is "Nothing"  I GET ERROR (91) next line and after
'What am I doing wrong?
For i = 0 To 10
Console.WriteLine(myvalues(i).Id(0), myvalues(i).Id(1), myvalues(i).Id(2), myvalues(i).Id(3), myvalues(i).Id(4), myvalues(i).Id(5), myvalues(i).Id(6))
Next i
End Sub
End Module
InformationsquelleAutor Matthew | 2012-07-21