Author 
Message 
Geoffrey Ch #1 / 6

Building a Matrix
Hi all!, i'm making a Matrix (like a chess table) but i don't know which is the correct data type to use. Each cell contains many fields. I tried using a dynamic multi array: Dim x() as Collection Redim Preserve x(1 to i ,1 to j) The problem is that the first column must be static. Another thing is that i have to create my own filter and sort functions. Which is the best approach? thanks in advance, Geoffrey

Fri, 17 Jan 2003 03:00:00 GMT 


Jonathan Alle #2 / 6

Building a Matrix
Use the Type keyword to create an UDT (User Defined Type). Type Checker King as Boolean Player as String End Type Then Redim x(0 to i, 0 to j) as Checker Note that you don't have to dim x before you redim it, but it doesn't hurt. Try to avoid Redim Preserve, it takes a long time to copy all of the data across. Jonathan Allen
Quote: > Hi all!, i'm making a Matrix (like a chess table) but i don't know which is > the correct data type to use. Each cell contains many fields. I tried using > a dynamic multi array: > Dim x() as Collection > Redim Preserve x(1 to i ,1 to j) > The problem is that the first column must be static. Another thing is that i > have to create my own filter and sort functions. > Which is the best approach? > thanks in advance, > Geoffrey

Fri, 17 Jan 2003 03:00:00 GMT 


Michel Wals #3 / 6

Building a Matrix
Hi, Each structure has its advantage. A matrix requires a minimum of storage, but, as you discovered, is limited to a simple scan each time you wish to find something.... Scanning is not a bad technique, if the number of things to be scanned is small. A collection, a single one, not an array of collection, allow you to retrieve an object on one key, so if everything you look for can be described by a single key, it may be useful to look for a collection. If many keys may be used, then a dictionary is probably preferable. Finally, if computations are required, like finding "those" appearing more than four time, key are not very immediately useful and a table plus a database engine may help much. If the dimensions are small, an array seems the best solution. Get a second array, a Boolean array, telling if the corresponding element in the first array satisfy the filter or not, if that can be useful, somehow, etc. You are not limited to just one data structure. Vanderghast, Access MVP
Quote: > Hi all!, i'm making a Matrix (like a chess table) but i don't know which is > the correct data type to use. Each cell contains many fields. I tried using > a dynamic multi array: > Dim x() as Collection > Redim Preserve x(1 to i ,1 to j) > The problem is that the first column must be static. Another thing is that i > have to create my own filter and sort functions. > Which is the best approach? > thanks in advance, > Geoffrey

Sat, 18 Jan 2003 03:00:00 GMT 


Geoffrey Ch #4 / 6

Building a Matrix
Hi!, thanks for your response...the problem is that i don't know the exact dimension of the matrix, and i have to preserve the values. To do it i have to use the: Redim Preserve Matrix(1 to k, 1 to j) but according to VB Help, to preserve the values the first index of the matrix must be static. I was wondering if using Recordsetconnectionless will be helpfull (an array of recordsets with the same fields, and each recordset containing a value of the structure or collection). The recordsets also provide Find, Sort and filter functions. Is it a good approach? thanks in advance... Geoffrey
Quote: > Use the Type keyword to create an UDT (User Defined Type). > Type Checker > King as Boolean > Player as String > End Type > Then > Redim x(0 to i, 0 to j) as Checker > Note that you don't have to dim x before you redim it, but it doesn't hurt. > Try to avoid Redim Preserve, it takes a long time to copy all of the data > across. > Jonathan Allen
> > Hi all!, i'm making a Matrix (like a chess table) but i don't know which > is > > the correct data type to use. Each cell contains many fields. I tried > using > > a dynamic multi array: > > Dim x() as Collection > > Redim Preserve x(1 to i ,1 to j) > > The problem is that the first column must be static. Another thing is that > i > > have to create my own filter and sort functions. > > Which is the best approach? > > thanks in advance, > > Geoffrey

Sat, 18 Jan 2003 03:00:00 GMT 


Jonathan Alle #5 / 6

Building a Matrix
First, add the X and Y locations to your UDT or Class definition. Thus, you go from a grid containing pieces to pieces with locations. You no longer have to worry about changing the board size. Instead, you just check the pieces for the topmost and bottommost location. Then you can store your data in either a collection or a recordset. The recordset will be harder to use,. but has more built in functionality. Jonathan Allen
Quote: > Hi!, thanks for your response...the problem is that i don't know the exact > dimension of the matrix, and i have to preserve the values. To do it i have > to use the: > Redim Preserve Matrix(1 to k, 1 to j) > but according to VB Help, to preserve the values the first index of the > matrix must be static. I was wondering if using Recordsetconnectionless > will be helpfull (an array of recordsets with the same fields, and each > recordset containing a value of the structure or collection). The recordsets > also provide Find, Sort and filter functions. Is it a good approach? > thanks in advance... > Geoffrey
> > Use the Type keyword to create an UDT (User Defined Type). > > Type Checker > > King as Boolean > > Player as String > > End Type > > Then > > Redim x(0 to i, 0 to j) as Checker > > Note that you don't have to dim x before you redim it, but it doesn't > hurt. > > Try to avoid Redim Preserve, it takes a long time to copy all of the data > > across. > > Jonathan Allen
> > > Hi all!, i'm making a Matrix (like a chess table) but i don't know which > > is > > > the correct data type to use. Each cell contains many fields. I tried > > using > > > a dynamic multi array: > > > Dim x() as Collection > > > Redim Preserve x(1 to i ,1 to j) > > > The problem is that the first column must be static. Another thing is > that > > i > > > have to create my own filter and sort functions. > > > Which is the best approach? > > > thanks in advance, > > > Geoffrey

Sat, 18 Jan 2003 03:00:00 GMT 


Geoffrey Ch #6 / 6

Building a Matrix
Well, the solution i implemented was using an UDT with recordsets Private Type Cell RS As Recordset End Type Private Matrix() As Cell By now is working fine, thanks folks. Geoffrey
Quote: > Hi, > Each structure has its advantage. A matrix requires a minimum of storage, > but, as you discovered, is limited to a simple scan each time you wish to > find something.... Scanning is not a bad technique, if the number of things > to be scanned is small. A collection, a single one, not an array of > collection, allow you to retrieve an object on one key, so if everything you > look for can be described by a single key, it may be useful to look for a > collection. If many keys may be used, then a dictionary is probably > preferable. Finally, if computations are required, like finding "those" > appearing more than four time, key are not very immediately useful and a > table plus a database engine may help much. If the dimensions are small, an > array seems the best solution. Get a second array, a Boolean array, telling > if the corresponding element in the first array satisfy the filter or not, > if that can be useful, somehow, etc. You are not limited to just one data > structure. > Vanderghast, Access MVP
> > Hi all!, i'm making a Matrix (like a chess table) but i don't know which > is > > the correct data type to use. Each cell contains many fields. I tried > using > > a dynamic multi array: > > Dim x() as Collection > > Redim Preserve x(1 to i ,1 to j) > > The problem is that the first column must be static. Another thing is that > i > > have to create my own filter and sort functions. > > Which is the best approach? > > thanks in advance, > > Geoffrey

Fri, 24 Jan 2003 03:00:00 GMT 


