Initializing Arrays

jliz2803

Newcomer
Joined
May 17, 2006
Messages
8
I am trying to Initialize some arrays with in a structure, and when the arrays are initialized the memory that they are being allocated to is all off. For example when I set whole(0) equal to something the value is being placed in amount(1) instead of whole(0) very odd. Below is the code I am using to create and initialize the arrays.
Code:
     Public Structure fee_inrecord
        <MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray)> Dim amount() As Double 'Path to data files
        <MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray)> Dim whole() As Double
        <MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray)> Dim min() As Double
        <MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray)> Dim max() As Double
        <MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray)> Dim exempt() As Double
        <MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray)> Dim tax() As Double
        <MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray)> Dim feetype() As Integer
        <MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray)> Dim base() As Integer
        <MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray)> Dim round() As Integer
        <MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray)> Dim blank() As Integer
        <MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray)> Dim handling() As Integer

        'UPGRADE_TODO: "Initialize" must be called to initialize instances of this structure. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="B4BFF9E0-8631-45CF-910E-62AB3970F27B"'
        Public Sub Initialize()
            ReDim amount(98)
            ReDim whole(98)
            ReDim min(98)
            ReDim max(98)
            ReDim exempt(98)
            ReDim tax(98)
            ReDim feetype(98)
            ReDim base(98)
            ReDim round(98)
            ReDim blank(98)
            ReDim handling(98)
        End Sub
    End Structure
It is like instead of allocating the first slots to amount(0), amount(1), amount(2)...etc it is doing amount(0), whole(0), min(0) so when it calls on the values everything is out of whatck any suggestions?
 
Can you post some code that accesses these arrays? It looks like there is some tricky marshalling going on here that could be causing you some problems.
 
Back
Top