Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I'm using Excel 2007 and I'm looking for an easy way to
implement something like a linked list of data or as a set that is found in other programming languages. I would like to be able to easily add or remove items from this list data structure. It would also be nice if I could dump the list data/contents into Excel cells. Anyone have any ideas or suggestions? Thank you! |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
After serious thinking Robert Crandal wrote :
I'm using Excel 2007 and I'm looking for an easy way to implement something like a linked list of data or as a set that is found in other programming languages. I would like to be able to easily add or remove items from this list data structure. It would also be nice if I could dump the list data/contents into Excel cells. Anyone have any ideas or suggestions? Thank you! Robert, can you provide more detail about what you're trying to do AND what exactly is your definition of 'a linked list'? -- Garry Free usenet access at http://www.eternal-september.org ClassicVB Users Regroup! comp.lang.basic.visual.misc |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sure, I probably wasnt very clear, so I'll try to just give
the basic gist of what I need. I was basically wondering if Visual Basic for Excel 2007 has some sort of data type that can hold a "set" of unique strings. I would like to be able to add or remove strings from this set and possibly iterate through the set of strings to see what the set contains. I realize that I could use an array of strings to implement a set of of strings, but that seems to be overkill and possibly time consuming. So, I'm basically wondering if Visual Basic provides some sort of a "set" data type or datastructure?? Does that make sense? Robert "GS" wrote in message ... Robert, can you provide more detail about what you're trying to do AND what exactly is your definition of 'a linked list'? |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On Dec 26, 12:33*am, "Robert Crandal" wrote:
Sure, I probably wasnt very clear, so I'll try to just give the basic gist of what I need. I was basically wondering if Visual Basic for Excel 2007 has some sort of data type that can hold a "set" of unique strings. I would like to be able to add or remove strings from this set and possibly iterate through the set of strings to see what the set contains. I realize that I could use an array of strings to *implement a set of of strings, but that seems to be overkill and possibly time consuming. So, I'm basically wondering if Visual Basic provides some sort of a "set" data type or datastructure?? *Does that make sense? Robert "GS" wrote in message ... Robert, can you provide more detail about what you're trying to do AND what exactly is your definition of 'a linked list'? I'm looking for something similar. Basically, I want a two dimensional array with a variable length. I can't believe that VBA does not have linked list. david |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Robert Crandal has brought this to us :
Sure, I probably wasnt very clear, so I'll try to just give the basic gist of what I need. I was basically wondering if Visual Basic for Excel 2007 has some sort of data type that can hold a "set" of unique strings. I would like to be able to add or remove strings from this set and possibly iterate through the set of strings to see what the set contains. I realize that I could use an array of strings to implement a set of of strings, but that seems to be overkill and possibly time consuming. So, I'm basically wondering if Visual Basic provides some sort of a "set" data type or datastructure?? Does that make sense? Robert Hi Robert, That's a bit more helpful but doesn't answer my Q about a 'linked list'. There is no data type that holds a 'set' of values as you describe. There are structures you could use to store and manipulate sets of data; namely an Array() or a Collection would be first chioces for unknown values/size at runtime. Both of these would let you add/remove/change the data however required. In both cases, you might want to store the data in a file (possibly encrypted) so it can be retrieved at startup and saved at shutdown. The UDT structure might work for known members at design time but you can only change the values at runtime (ergo you can't add/remove members at runtime). The easiest approach <IMO would be to use a variable defined as Variant data type. This would allow you to manipulate the data using VB[A]'s Split() and Join() functions as well as the Filter() function to remove blank elements resulting from deleted data. I'd use a delimited string for each record of data so it fits nicely into a one dim array. Parsing each record is fairly easy and straight forward using the Split() function. Optionally, depending on how the storage is structured, you could use ADO to manage the data in 'sets' based on criteria you define. HTH -- Garry Free usenet access at http://www.eternal-september.org ClassicVB Users Regroup! comp.lang.basic.visual.misc |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I know I didnt answer the question about a "linked list". I
thought it would be better if I just forget about linked lists because it is an abstract data type that is often implemented in the C/C++ programming language. Basically, a "linked list" is a set of data structures or "nodes" that is in sequence; ie, the list has a beginning (i.e "head") and and an end (i.e "tail"). Each node contains data, in addition to a "next" pointer which points to the next node in the list. Below is a text/graphical depiction of a linked list with 6 nodes. H is the head node, T is the tail node, and all the other nodes are marked as N. Each node has an arrow or pointer which points to the next node. [H]--[N]--[N]--[N]--[N]--[T] The nice thing about linked lists is that you can make them dynamically grow or shink, by adding or deleting nodes. So, a linked list is ALMOST like an array. The main difference is that an array size is usually fixed, but a linked list can dynamically grow and new nodes can be inserted anywhere in the middle of the list. Is this really your first experience with linked lists?? "GS" wrote in message ... That's a bit more helpful but doesn't answer my Q about a 'linked list'. |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Robert Crandal explained :
I know I didnt answer the question about a "linked list". I thought it would be better if I just forget about linked lists because it is an abstract data type that is often implemented in the C/C++ programming language. Basically, a "linked list" is a set of data structures or "nodes" that is in sequence; ie, the list has a beginning (i.e "head") and and an end (i.e "tail"). Each node contains data, in addition to a "next" pointer which points to the next node in the list. Below is a text/graphical depiction of a linked list with 6 nodes. H is the head node, T is the tail node, and all the other nodes are marked as N. Each node has an arrow or pointer which points to the next node. [H]--[N]--[N]--[N]--[N]--[T] The nice thing about linked lists is that you can make them dynamically grow or shink, by adding or deleting nodes. So, a linked list is ALMOST like an array. The main difference is that an array size is usually fixed, but a linked list can dynamically grow and new nodes can be inserted anywhere in the middle of the list. Is this really your first experience with linked lists?? Well, I don't have any experience with linked lists. I'm afraid my programming experience is limited to VB/VBA, HTML, and some vbScript. I've read about this while exploring Delphi as a possible candidate for my next gen dev language. I think it's a great concept, though. I get a similar effect using a one dim array with [delimited] string elements. Since arrays don't dynamically resize when deleting the contents of an element, the Filter() function trims out any empty elements and returns a newly sized array. For example, if myArray has 10 elements (0 T0 9) and I empty elements 2 and 6, the Filter() function resizes the array to 8 elements (0 To 7). (What happens is elements 3-5 shift one position, elements 7-10 shift 2 positions) This makes for a very flexible structure where, for example, each element of my one dim array can hold an array (thus making it an array of arrays) if I choose. Usually, I store delimited strings that I parse into a temp array when I want to use the data. I find this approach a bit faster and easier to manage size-wise. So, for example, if you stored your data in a text file where each 'record' of data was on a separate line then you could quickly dump the file contents into a 'dynamic' array using Split() and specifying vbCrLf as the delimiter. (Conversely, writing back is a simple matter of using Join() and specifying vbCrLf as the delimiter) I like to store field names (headings) in the first row so element 1 of myArray is the first record and UBound(myArray) is the number of records. It also makes it easier to dump the data onto a spreadsheet. (..subject to worksheet row limit) -- Garry Free usenet access at http://www.eternal-september.org ClassicVB Users Regroup! comp.lang.basic.visual.misc |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Robert,
when I taught data structures in the 1980's I used BBC Basic to demonstrate how a linked list structure could be implemented. A 1-D string array was used to hold the data and a numeric array held the pointers. In addition, a free-space pointer pointed to the next available element of the array. As data was added (in any order) the pointers were adjusted to maintain the correct sequence. If data is deleted then the free space pointer is adjusted, along with the pointer of the element which is removed and the pointer which pointed to that element. It can also be beneficial to have another set of pointers which point back to the previous data item, so that the list can be searched in both directions. I haven't tried to implement this using VBA, but similar approaches could be taken. Hope this helps. Pete On Dec 26, 8:38*pm, "Robert Crandal" wrote: I know I didnt answer the question about a "linked list". *I thought it would be better if I just forget about linked lists because it is an abstract data type that is often implemented in the C/C++ programming language. Basically, a "linked list" is a set of data structures or "nodes" that is in sequence; ie, the list has a beginning (i.e "head") and and an end (i.e "tail"). *Each node contains data, in addition to a "next" pointer which points to the next node in the list. Below is a text/graphical depiction of a linked list with 6 nodes. *H is the head node, T is the tail node, and all the other nodes are marked as N. *Each node has an arrow or pointer which points to the next node. * [H]--[N]--[N]--[N]--[N]--[T] The nice thing about linked lists is that you can make them dynamically grow or shink, by adding or deleting nodes. So, a linked list is ALMOST like an array. *The main difference is that an array size is usually fixed, but a linked list can dynamically grow and new nodes can be inserted anywhere in the middle of the list. Is this really your first experience with linked lists?? "GS" wrote in message ... That's a bit more helpful but doesn't answer my Q about a 'linked list'..- Hide quoted text - - Show quoted text - |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Use VBA to reset data validation (=list) value to first value in that list (list is a named range) | Excel Programming | |||
data validation list: how do i 'force' a user to enter data from the list? | Excel Discussion (Misc queries) | |||
data validation list: how do i 'force' a user to enter data from the list? | Excel Discussion (Misc queries) | |||
How to view a list of data based on another list of data | Excel Discussion (Misc queries) | |||
converting vertical data list to horizontal data list | Excel Worksheet Functions |