Is a Array of Structures allowed in VB.net ?

Discussion in 'Visual Studio' started by albanello, Sep 30, 2007.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. If the answer is yes could somebody tell me why this code does not work:




    Structure LookUpStructTag
    Dim DataGridID As Integer
    Dim TableName As String
    Dim DataSetName As String
    Public Sub New(ByVal argValue As EnumClass.DataGridID, ByVal argStr_0 As String, ByVal argStr_1 As String)
    DataGridID = argValue
    TableName = argStr_0
    DataSetName = argStr_1
    End Sub
    End Structure

    Private arrLookUpStruct(10) As Array

    arrLookUpStruct.SetValue(New LookUpStructTag(EnumClass.DataGridID.DRW_DATA_ID, "TestNumber", "TestTable"), 0)

    Here is the error:
    </CODE>

    [InvalidCastException: Object cannot be stored in an array of this type.]
    System.Array.InternalSetValue(Object value, Int32 index1, Int32 index2, Int32 index3) +0
    LotteryApp.LotteryClassTag..ctor(LotteryID argLotteryID) +250
    LotteryApp.LOTClassTag..ctor(LotteryID argLotteryID) +108
    LotteryApp.LOTPage.Page_Load(Object sender, EventArgs e) +221
    System.Web.UI.Control.OnLoad(EventArgs e) +67
    System.Web.UI.Control.LoadRecursive() +35
    System.Web.UI.Page.ProcessRequestMain() +750

    Thanks in advance
    albanello
     
  2. To declare an array of LookUpStructTag structures:

    Private arrLookUpStruct(10) As LookUpStructTag

    Aristotle

    DiscountASP.NET
    www.DiscountASP.NET
     
  3. Thanks Aristotle


    So what I did only delared a Array it did not define the type of object. Your solution defines a Array and defines the objects in the array as LookUpStructTag structtures.


    I will try it tonight.


    albanello
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page