Login
Search   Moderators Wanted: If you're interested please send your portfolio to info[at]itechforums.com
Welcome to the iTechForums.
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.
To register now click here.
Latest Threads
Advertisements
Forum Statistics
Threads:
Posts: 1
Members:
Number of Users Online:
Welcome to our newest member,
Reply
 
Thread Tools Display Modes
  #1  
Old 10-22-2009, 06:22 PM
Jon B. Jon B. is offline
Junior Member
 
Join Date: Oct 2009
Posts: 1
Default

How do I properly initialize a multidimensional array within a structure in VB .NET?


How do I properly initialize a multidimensional array within a structure in VB .NET?

I thought I understood how the structure was initialized but I seem to be misunderstanding the scope concept.
I have a structure defined:

Public Structure data
Public x(,) As integer ' multidimensional array.
Sub New(ByVal i as integer) ' Constructor sub
ReDim x(i, i) ' Redim to proper bounds
End Sub
End Structure

Public Shared d() as data

Then I have a private sub.

Private Sub MakeNew()
ReDim data(3)
data(0).x(0, 0) = 1
End Sub

What I'm wanting to happen is have an arrayed structure with a 2D array within. But when I try to access the nested 2D array it gives me a: Object reference not set to an instance of an object. exception.

Can anyone help me figure this out?
I'm still pretty new to VB so I assume I'm just missing something here.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[VB.NET] multidimensional array help? Chris Yuki .Net (ASP.Net, VB.Net, C#) 2 07-03-2009 01:23 PM
how do you put data into a multidimensional array PHP? Chris PHP 0 02-17-2009 11:15 PM
PHP Multidimensional Associative Array question? redsox0077 PHP 1 02-14-2009 07:51 PM
how to initialize array in an algorithm? Tasrif Software Design & Algorithms 1 10-22-2008 03:53 PM
Is there a way to manipulate a multidimensional Array ay VB.NET? Dong .Net (ASP.Net, VB.Net, C#) 0 08-07-2008 12:03 AM

Your Ad Here

All times are GMT. The time now is 03:29 AM.