| Register | FAQ | Calendar | Search | Today's Posts | Mark Forums Read |
|
#1
|
| Does anyone have any good ideas about the best way to represent a dynamic array in VB.NET? I'm looking to use it as a temporary, in memory store, not as a complex database. At first I thought to use a three-dimensional array, but that quickly fell apart (redimensioning doesn't work the way MV needs). Then I thought of using some kind of collection, but that looks complex to implement as a three-dimensional store. mv.NET is not an option in this project. Does anyone have any ideas? Or better yet, has anyone actually done it? Thanks. |
|
#2
|
| You can use "array of arrays" (not to be confused with multi- dimensioned arrays) or "collection of collections" to nest your data any number of levels deep. I assume, though, you'll want to somehow be able to serialize/ deserialize dynamic array data as well. In that case, you'll need to build your own functions to do so. rex |
|
#3
|
| sh wrote: > Does anyone have any good ideas about the best way to represent a > dynamic array in VB.NET? > > I'm looking to use it as a temporary, in memory store, not as a complex > database. > > At first I thought to use a three-dimensional array, but that quickly > fell apart (redimensioning doesn't work the way MV needs). Then I > thought of using some kind of collection, but that looks complex to > implement as a three-dimensional store. > > mv.NET is not an option in this project. > > Does anyone have any ideas? Or better yet, has anyone actually done it? > > Thanks. According to the UniObjects for .Net Developer's Guide you would use the UniDynArray Class. This is if you are a UniVerse or UniData developer. Ron White -- Posted via NewsDemon.com - Premium Uncensored Newsgroup Service ------->>>>>>http://www.NewsDemon.com<<<<<<------ Unlimited Access, Anonymous Accounts, Uncensored Broadband Access |
|
#4
|
| Rex Gozar wrote: > You can use "array of arrays" (not to be confused with multi- > dimensioned arrays) or "collection of collections" to nest your data > any number of levels deep. > > I assume, though, you'll want to somehow be able to serialize/ > deserialize dynamic array data as well. In that case, you'll need to > build your own functions to do so. > > rex Have you ever done it? It looks like it would be quite complicated to implement, or am I just imagining it. It looks to me like collections would be the way to go - no need to keep track of dimensions and having to redim them. |
|
#5
|
| On Aug 8, 7:33 pm, sh > Does anyone have any good ideas about the best way to represent a > dynamic array in VB.NET? > > I'm looking to use it as a temporary, in memory store, not as a complex > database. > > At first I thought to use a three-dimensional array, but that quickly > fell apart (redimensioning doesn't work the way MV needs). Then I > thought of using some kind of collection, but that looks complex to > implement as a three-dimensional store. > > mv.NET is not an option in this project. > > Does anyone have any ideas? Or better yet, has anyone actually done it? > > Thanks. ROFL why bother? |
|
#6
|
| "sh" news:VNKdnTKK8I_5DAHVnZ2dnUVZ_u2dnZ2d-at-earthlink.co m... > Does anyone have any good ideas about the best way to represent a dynamic > array in VB.NET? > > I'm looking to use it as a temporary, in memory store, not as a complex > database. > > At first I thought to use a three-dimensional array, but that quickly fell > apart (redimensioning doesn't work the way MV needs). Then I thought of > using some kind of collection, but that looks complex to implement as a > three-dimensional store. > > mv.NET is not an option in this project. > > Does anyone have any ideas? Or better yet, has anyone actually done it? > > Thanks. Just to create dynamic array-like functionality, create an "object" with these properties (or something similar) public xRec as string =vbnullstring ' define dynamic array somewhere public default overloads property AVS() get try return xrec catch ex as exception return vbnullstring end try end get set (byval value as string) try xrec = value catch ex as exception end try end set end property public overloads property AVS(byVal iAttr as integer) dim XX(1) as string get try xx = split(xrec,Chr(254)) return xx(iAttr-1) ' zero-relative catch ex as exception return vbnullstirng ' outside range of existing attributes end try end get set(byval value as string) try xx = split(xrec,chr(254)) ' split the array into segments ' if they replace a value higher than we have, build up to it if iAttr-1 > ubound(xx) then redim xx(iAttr-1) ' redimension the array bigger xx(iAttr-1) = value ' replace value xrec = join(xx,Chr(254)) ' put it back together again catch ex as exception end try end set end property public overloads property AVS(byVal iAttr as Integer, byval iVal as Integer) dim XX(1) as string, YY(1) as string get try XX = split(xrec,Chr(254)) YY = split(xx(iAttr-1),Chr(253)) return YY(iVal-1) ' zero-relative catch ex as exception return vbnullstirng ' outside range of existing attributes end try end get set(byval value as string) try XX = split(xrec,chr(254)) ' split the array into segments if iAttr-1 > ubound(XX) then redim xx(iAttr-1) ' redimension the array bigger YY = split(XX(iAttr-1),Chr(253)) if iVal-1 > ubound(YY) then redim YY(iVal-1) YY(iVal -1) = value ' replace value XX(iAttr-1) = join(YY,Chr(253)) xrec = join(xx,Chr(254)) ' put it back together again catch ex as exception end try end set end property You get the idea. You can carry this on to as many levels as you want to define delimiters (chr(251), ~, \ etc etc) Mark |
|
#7
|
| Mark Looks interesting. I never thought of it this way. I'll give it a look. When I did a copy & paste into a new class, I got a load of error messages. I guess you posted it quickly. I'll have to clean it up to see how it works. Thanks Mark Brown wrote: > "sh" > news:VNKdnTKK8I_5DAHVnZ2dnUVZ_u2dnZ2d-at-earthlink.co m... >> Does anyone have any good ideas about the best way to represent a >> dynamic array in VB.NET? >> >> I'm looking to use it as a temporary, in memory store, not as a >> complex database. >> >> At first I thought to use a three-dimensional array, but that quickly >> fell apart (redimensioning doesn't work the way MV needs). Then I >> thought of using some kind of collection, but that looks complex to >> implement as a three-dimensional store. >> >> mv.NET is not an option in this project. >> >> Does anyone have any ideas? Or better yet, has anyone actually done it? >> >> Thanks. > > > Just to create dynamic array-like functionality, create an "object" with > these properties (or something similar) > > public xRec as string =vbnullstring ' define dynamic array somewhere > public default overloads property AVS() > get > try > return xrec > catch ex as exception > return vbnullstring > end try > end get > set (byval value as string) > try > xrec = value > catch ex as exception > end try > end set > end property > public overloads property AVS(byVal iAttr as integer) > dim XX(1) as string > get > try > xx = split(xrec,Chr(254)) > return xx(iAttr-1) ' zero-relative > catch ex as exception > return vbnullstirng ' outside range of existing attributes > end try > end get > set(byval value as string) > try > xx = split(xrec,chr(254)) ' split the array into segments > ' if they replace a value higher than we have, build up to it > if iAttr-1 > ubound(xx) then redim xx(iAttr-1) ' > redimension the array bigger > xx(iAttr-1) = value ' replace value > xrec = join(xx,Chr(254)) ' put it back together again > catch ex as exception > end try > end set > end property > public overloads property AVS(byVal iAttr as Integer, byval iVal as > Integer) > dim XX(1) as string, YY(1) as string > get > try > XX = split(xrec,Chr(254)) > YY = split(xx(iAttr-1),Chr(253)) > return YY(iVal-1) ' zero-relative > catch ex as exception > return vbnullstirng ' outside range of existing attributes > end try > end get > set(byval value as string) > try > XX = split(xrec,chr(254)) ' split the array into segments > if iAttr-1 > ubound(XX) then redim xx(iAttr-1) ' > redimension the array bigger > YY = split(XX(iAttr-1),Chr(253)) > if iVal-1 > ubound(YY) then redim YY(iVal-1) > YY(iVal -1) = value ' replace value > XX(iAttr-1) = join(YY,Chr(253)) > xrec = join(xx,Chr(254)) ' put it back together again > catch ex as exception > end try > end set > end property > > You get the idea. You can carry this on to as many levels as you want > to define delimiters (chr(251), ~, \ etc etc) > > > Mark |
|
#8
|
| "sh" news:QtednaCnFsoM2j3VnZ2dnUVZ_g2dnZ2d-at-earthlink.co m... > Mark > > Looks interesting. I never thought of it this way. I'll give it a look. > > When I did a copy & paste into a new class, I got a load of error > messages. I guess you posted it quickly. I'll have to clean it up to see > how it works. > > Thanks > Let me know if you need more specific help. I typed it in from memory and didn't add all the properties and methods. Mark |
|
#9
|
| sh, Here's a link with some how-to info on VB.NET collections: http://www.java2s.com/Tutorial/VB/01...Collection.htm If you really are trying to create temporary storage, collections is probably the way to go. But it seems that you are unintentionally constrained by "multi-value thinking". You didn't say whether or not your need to serialize/ deserialize the data; since it's temporary I'm going to assume "no". That being the case, it might be better to think of your data in terms of "structures within a structure". Instead of associating {name, name, name} with {city, city, city}, try thinking in terms of { {name, city}, {name, city}, {name, city} } storing the associated data together as separate structures (i.e. collections). rex |
|
#10
|
| Mark Thanks so much for your code snippet. I took the snippet, and created a whole class, including Insert, Delete, and DCount methods and functions. I'd be glad to post it, but I'm not sure a post here is the best way to go with it. I'd be happy to e-mail it to whoever is interested, or perhaps post it to some multi-value site. However, I wrote it the "quick and dirty" way. I'm not so happy with some of the syntax (some of it doesn't feel Pickie or VB). I can see some places that can use some tightening up, or perhaps better ideas of how to implement it, so I'd first like to get some "peer review" of it. But it's really just an extension of your ideas, Mark. Can I e-mail it to you first, Mark? Anyone else interested in looking at it? BTW Mark, I wasn't able to get those "default" methods to work. On the first method, I got an error message saying that you cannot default a method that has no parameter list. So I'm left with mvRec.Item as the necessary syntax. Maybe you have a better way of doing it. Sholom Mark Brown wrote: > "sh" > news:QtednaCnFsoM2j3VnZ2dnUVZ_g2dnZ2d-at-earthlink.co m... >> Mark >> >> Looks interesting. I never thought of it this way. I'll give it a look. >> >> When I did a copy & paste into a new class, I got a load of error >> messages. I guess you posted it quickly. I'll have to clean it up to >> see how it works. >> >> Thanks >> > > > Let me know if you need more specific help. I typed it in from memory > and didn't add all the properties and methods. > > > Mark > |
![]() |
| Thread Tools | |
| Display Modes | |