Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have my own dynamic array
Type LinkInfo href As String InnerText As String End Type Dim Links() As LinkInfo which I am redimensioning as I go along but I have the need to delete an array element, e.g. links(5) from the middle of the array when its upper bound is 10 How do I do this please. I can only find the erase method to purge the whole array -- Mike |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On Sun, 13 Mar 2005 at 05:14:31, Mike NG (Mike NG
) wrote: I have my own dynamic array Type LinkInfo href As String InnerText As String End Type Dim Links() As LinkInfo which I am redimensioning as I go along but I have the need to delete an array element, e.g. links(5) from the middle of the array when its upper bound is 10 How do I do this please. I can only find the erase method to purge the whole array I've also tried Links.Remove 5, but this doesn't appear to work It appears as though I have to filter my array to a new array and copy everything over manually -- Mike |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Mike,
There is a simpler way using Filter. Here is an example Dim vMatch Dim i As Long Dim ary ary = Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10) For i = LBound(ary) To UBound(ary) Debug.Print ary(i) Next i vMatch = Chr(255) ary(7) = vMatch ' change the 8 ary = Filter(ary, vMatch, False) For i = LBound(ary) To UBound(ary) Debug.Print ary(i) Next i -- HTH RP (remove nothere from the email address if mailing direct) "Mike NG" wrote in message ... On Sun, 13 Mar 2005 at 05:14:31, Mike NG (Mike NG ) wrote: I have my own dynamic array Type LinkInfo href As String InnerText As String End Type Dim Links() As LinkInfo which I am redimensioning as I go along but I have the need to delete an array element, e.g. links(5) from the middle of the array when its upper bound is 10 How do I do this please. I can only find the erase method to purge the whole array I've also tried Links.Remove 5, but this doesn't appear to work It appears as though I have to filter my array to a new array and copy everything over manually -- Mike |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Is there a Filter function that works with 2-D arrays?
RBS "Bob Phillips" wrote in message ... Mike, There is a simpler way using Filter. Here is an example Dim vMatch Dim i As Long Dim ary ary = Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10) For i = LBound(ary) To UBound(ary) Debug.Print ary(i) Next i vMatch = Chr(255) ary(7) = vMatch ' change the 8 ary = Filter(ary, vMatch, False) For i = LBound(ary) To UBound(ary) Debug.Print ary(i) Next i -- HTH RP (remove nothere from the email address if mailing direct) "Mike NG" wrote in message ... On Sun, 13 Mar 2005 at 05:14:31, Mike NG (Mike NG ) wrote: I have my own dynamic array Type LinkInfo href As String InnerText As String End Type Dim Links() As LinkInfo which I am redimensioning as I go along but I have the need to delete an array element, e.g. links(5) from the middle of the array when its upper bound is 10 How do I do this please. I can only find the erase method to purge the whole array I've also tried Links.Remove 5, but this doesn't appear to work It appears as though I have to filter my array to a new array and copy everything over manually -- Mike |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
We wish :-)
-- HTH RP (remove nothere from the email address if mailing direct) "RB Smissaert" wrote in message ... Is there a Filter function that works with 2-D arrays? RBS "Bob Phillips" wrote in message ... Mike, There is a simpler way using Filter. Here is an example Dim vMatch Dim i As Long Dim ary ary = Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10) For i = LBound(ary) To UBound(ary) Debug.Print ary(i) Next i vMatch = Chr(255) ary(7) = vMatch ' change the 8 ary = Filter(ary, vMatch, False) For i = LBound(ary) To UBound(ary) Debug.Print ary(i) Next i -- HTH RP (remove nothere from the email address if mailing direct) "Mike NG" wrote in message ... On Sun, 13 Mar 2005 at 05:14:31, Mike NG (Mike NG ) wrote: I have my own dynamic array Type LinkInfo href As String InnerText As String End Type Dim Links() As LinkInfo which I am redimensioning as I go along but I have the need to delete an array element, e.g. links(5) from the middle of the array when its upper bound is 10 How do I do this please. I can only find the erase method to purge the whole array I've also tried Links.Remove 5, but this doesn't appear to work It appears as though I have to filter my array to a new array and copy everything over manually -- Mike |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Yes, didn't think there was.
Luckily, just looping through the array elements is quite fast. RBS "Bob Phillips" wrote in message ... We wish :-) -- HTH RP (remove nothere from the email address if mailing direct) "RB Smissaert" wrote in message ... Is there a Filter function that works with 2-D arrays? RBS "Bob Phillips" wrote in message ... Mike, There is a simpler way using Filter. Here is an example Dim vMatch Dim i As Long Dim ary ary = Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10) For i = LBound(ary) To UBound(ary) Debug.Print ary(i) Next i vMatch = Chr(255) ary(7) = vMatch ' change the 8 ary = Filter(ary, vMatch, False) For i = LBound(ary) To UBound(ary) Debug.Print ary(i) Next i -- HTH RP (remove nothere from the email address if mailing direct) "Mike NG" wrote in message ... On Sun, 13 Mar 2005 at 05:14:31, Mike NG (Mike NG ) wrote: I have my own dynamic array Type LinkInfo href As String InnerText As String End Type Dim Links() As LinkInfo which I am redimensioning as I go along but I have the need to delete an array element, e.g. links(5) from the middle of the array when its upper bound is 10 How do I do this please. I can only find the erase method to purge the whole array I've also tried Links.Remove 5, but this doesn't appear to work It appears as though I have to filter my array to a new array and copy everything over manually -- Mike |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On Sun, 13 Mar 2005 at 12:02:32, Bob Phillips (Bob Phillips
) wrote: We wish :-) Cheers Bob Nice idea - except my array of type LinkInfo is effectively 2D isn't it? -- Mike |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Mike NG wrote:
I have my own dynamic array Type LinkInfo href As String InnerText As String End Type Dim Links() As LinkInfo which I am redimensioning as I go along but I have the need to delete an array element, e.g. links(5) from the middle of the array when its upper bound is 10 How do I do this please. I can only find the erase method to purge the whole array Is Links a one-column array? Alan Beban |
#9
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On Sun, 13 Mar 2005 at 12:41:22, Alan Beban (Alan Beban
) wrote: Mike NG wrote: I have my own dynamic array Type LinkInfo href As String InnerText As String End Type Dim Links() As LinkInfo which I am redimensioning as I go along but I have the need to delete an array element, e.g. links(5) from the middle of the array when its upper bound is 10 How do I do this please. I can only find the erase method to purge the whole array Is Links a one-column array? Depends what you mean, but each element of the Links() array is of type LinkInfo I have decided to carry on using arrays. For the sake of being able to use add and delete easily, referencing the elements as (0), (1), (2) etc is not as friendly as using .href, .Innertext etc -- Mike |
#10
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
If you have a need to remove an element from the middle of an 'array'
then an array is probably the wrong data type structure to begin with. Consider a linked list. How To Implement a Linked List in Visual Basic http://support.microsoft.com/default...b;en-us;166394 -- Regards, Tushar Mehta www.tushar-mehta.com Excel, PowerPoint, and VBA add-ins, tutorials Custom MS Office productivity solutions In article , says... I have my own dynamic array Type LinkInfo href As String InnerText As String End Type Dim Links() As LinkInfo which I am redimensioning as I go along but I have the need to delete an array element, e.g. links(5) from the middle of the array when its upper bound is 10 How do I do this please. I can only find the erase method to purge the whole array |
#11
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On Mon, 14 Mar 2005 at 19:25:10, Tushar Mehta (Tushar Mehta
) wrote: If you have a need to remove an element from the middle of an 'array' then an array is probably the wrong data type structure to begin with. Consider a linked list. How To Implement a Linked List in Visual Basic http://support.microsoft.com/default...b;en-us;166394 Cool never thought of that May consider this for a future project -- Mike |
#12
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
you might want to investigate the Scripting.Dictionary object as well. Hth, O |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Set array element to empty | Excel Programming | |||
Array Element question | Excel Programming | |||
Array element | Excel Programming | |||
Deleting data and element in a 1D array | Excel Programming | |||
deleting array element | Excel Programming |