I need a container to hold an array ... thought I would be able to use a structure but an array's size can't be defined in the structure ... the examples suggest this is done using a redim statement but this is also an issue because redim is not allowed outside a sub or function ... I need these containers to be static/global. I was wondering if there is a way to define the array for this example? Or do I need to define this Struct as another Class? Either way I would like to generate a global container that includes an array.
' VB 2010 Express
Public CLASS X
Public Structure Fifo
DIM Head as Integer
DIM Tail as Integer
DIM Count as Integer
DIM Buf(50)as String ' causes error Array Size can't be assigned in structure
End Structure
Public Alpha As New Fifo
Public Beta As New Fifo
Private Sub Form_Load()
DIM inI as Integer
' init
Alpha.Head = 0
Alpha.Tail = 0
Alpha.Count = 0
Beta.Head = 0
Beta.Tail = 0
Beta.Count = 0
for inI = 0 to 50 step 1
Alpha.buf(inI) = ""
Beta.buf(inI) = ""
next
End Sub
End Class
' VB 2010 Express
Public CLASS X
Public Structure Fifo
DIM Head as Integer
DIM Tail as Integer
DIM Count as Integer
DIM Buf(50)as String ' causes error Array Size can't be assigned in structure
End Structure
Public Alpha As New Fifo
Public Beta As New Fifo
Private Sub Form_Load()
DIM inI as Integer
' init
Alpha.Head = 0
Alpha.Tail = 0
Alpha.Count = 0
Beta.Head = 0
Beta.Tail = 0
Beta.Count = 0
for inI = 0 to 50 step 1
Alpha.buf(inI) = ""
Beta.buf(inI) = ""
next
End Sub
End Class