Arrays in Structures of VB.NET


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Arrays in Structures of VB.NET

  1. #1
    Sathya Ramanathan Guest

    Arrays in Structures of VB.NET

    I have a VB code which goes like

    Public Type FocJob
    data(11) as string
    End Type

    When I am converting to VB.NET, i am using structures

    1 : Public Structure FocJob
    2 : Dim data(11) as string
    3 : End Structure

    Line 2 shows an error says "Arrays declared as structure members cannot be
    declared with initial size"

    Any help would be appreciated.

    Thanks
    Sathya



  2. #2
    VBDotNet Team [MS] Guest

    Re: Arrays in Structures of VB.NET

    In VB.NET, you cannot specify the size of the array like that. What you can
    do instead is declare your structure like this:

    Public Structure FocJob
    Dim data() as string
    End Structure

    then you can create the array in code like that:

    Dim f as new FocJob()
    f.data = new string(11) {}


    Hope this helps

    Antoine Cote (Dev) & Aiwen Guo (Test)


    --
    This posting is provided "AS IS" with no warranties, and confers no rights.

    "Sathya Ramanathan" <sathya.ramanathan@ttu.edu> wrote in message
    news:3d177338$1@10.1.10.29...
    > I have a VB code which goes like
    >
    > Public Type FocJob
    > data(11) as string
    > End Type
    >
    > When I am converting to VB.NET, i am using structures
    >
    > 1 : Public Structure FocJob
    > 2 : Dim data(11) as string
    > 3 : End Structure
    >
    > Line 2 shows an error says "Arrays declared as structure members cannot be
    > declared with initial size"
    >
    > Any help would be appreciated.
    >
    > Thanks
    > Sathya
    >
    >




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center