Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I've made those structures

   Public Structure typeObiektStrony
       Dim Left As Integer
       Dim Top As Integer
       Dim Width As Integer
       Dim Height As Integer
       Dim Value As String
       Dim Text As String
       Dim ToolTipText As String
   End Structure
   Public Structure typeStrony
       Dim BackGround As Image
       Dim BakcColor As Color
       Dim Width As Integer
       Dim Height As Integer
       Dim Obiekty() As typeObiektStrony
   End Structure
   Dim dc As typeStrony

 

when I try to get dc.Obiekty(i).Left the 'System.NullReferenceException' appears. It's probably beacous the number of elements in obiekty array is not specified. I realy don't know how to do this.

 

I've searched the forum, msdn and help files... please help me...

  • *Experts*
Posted

You need to redim the array Obiekty. I'm not sure if the ReDimming part is right - someone can correct me later :)

 

   'Snipped the structs definitions...
   Dim dc As typeStrony

   ReDim dc.Obiekty(1)
   dc.Obiekty(0).Left = 14
   
   'The following will fail because Obiekty is only defined to have one element, (0)
   dc.Obiekty(1).Left = 14

 

-Nerseus

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Posted

I supose: When You are trying to use array in array then

redim dc.Obiekty(20)
redim dc.Obiekty(0).CosTam(20)
redim dc.Obiekty(1).CosTam(20)
redim dc.Obiekty(2).CosTam(20)
...
redim dc.Obiekty(20).CosTam(20)

writing just

redim dc.Obiekty(20).CosTam(20)

won't be enoguht to create array with 21 Obiekty and 21 CosTam in it. Am I right?

 

And the last question: When I use ReDim in Load event then whole Module will 'know' that there are 21 Obietkty in this array. Right?

  • Leaders
Posted

Yes, you have to Redim each dynamic array that you have... you could do it in a loop:

Dim LV As Integer
Redim dc.Obiekty(20)
For LV = 0 To 20
 Redim dc.Obiekty(LV).CosTam(20)
Next

And the last question: When I use ReDim in Load event

That depends on where you have declared the original Dim... if you declared it in your main module general area, then the whole module will know, but if you define it in the Load event, then only the Load event will know... but the ReDim can be anywhere... preferably before you start operating with the arrays. :)

Iceplug, USN

One of my coworkers thinks that I believe that drawing bullets is the most efficient way of drawing bullets. Whatever!!! :-(

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...