Basic4ppc - Windows Mobile Development  

Go Back   Basic4ppc - Windows Mobile Development > Main Category > Questions & Help Needed
Home Register FAQ Members List Search Today's Posts Mark Forums Read

Questions & Help Needed Post any question regarding Basic4ppc.


ArrayList bidimensional?


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-16-2008, 07:17 PM
Newbie
 
Join Date: Jun 2008
Posts: 5
Default ArrayList bidimensional?

Hello,

Somebody knows if an ArrayList could be bi-dimensional?, or if i have a structure like this:

Dim Type(X,Y) ElementList(0)

How could i redim this array?

Thanks!
Reply With Quote
  #2 (permalink)  
Old 07-16-2008, 07:32 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 3,186
Default

ArrayLists can only have one dimension.
You can redim this array with"
Code:
Dim ElementList(10,2) '10 - new size, 2 - number of fields.
Reply With Quote
  #3 (permalink)  
Old 07-17-2008, 09:38 PM
Newbie
 
Join Date: Jun 2008
Posts: 5
Default

it worked, thx... and, could you tell me how i could redim (add or delete elemenst to the array) without lossing the current data?

Thanks again!
Reply With Quote
  #4 (permalink)  
Old 07-18-2008, 10:15 AM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 3,186
Default

You will need to manually copy the data each time.
Something like:
Code:
Sub Globals
    'Declare the global variables here.
    Dim Type(x,y) ElementList(0)
    Dim Type(x,y) TempList(0)
End Sub

Sub App_Start
    'usage example
    Redim(10)
    For i = 0 To 9
        ElementList(i).x = i
        ElementList(i).y = i * 2
    Next
    Redim(100)
    Msgbox(ElementList(5).x,ElementList(4).y)
End Sub

Sub Redim(size)
    Dim TempList(size,2)
    For i = 0 To ArrayLen(ElementList())-1
        TempList(i).x = ElementList(i).x
        TempList(i).y = ElementList(i).y
    Next
    ElementList() = TempList() 'Both arrays will point to the same array.
End Sub
Don't call this method periodically. Instead set the array size to be larger than what you currently need (at least twice the size).
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
ArrayList Bobbes German Forum 2 02-25-2008 09:36 PM
ControlType for ArrayList glook Bug Reports 2 02-18-2008 11:31 AM
ArrayList won't dispose? willisgt Questions & Help Needed 1 08-30-2007 08:56 PM
Arraylist tvrman Questions & Help Needed 7 07-01-2007 11:42 AM
listbox = arraylist ? sloopa Questions & Help Needed 1 05-07-2007 01:38 PM


All times are GMT. The time now is 12:35 PM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.1.0