Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Zwi Zwi is offline
external usenet poster
 
Posts: 1
Default Dictionary objet

Hi all,

I wish to use the Dictionary object but with some modifications as follows:

At the "Add method" to have a third option to sum up the frequency of
that "key".

At the "Remove method" do remove the item if that third key above has
frequency of 1, otherwise reduce that key by 1.

Is this possible?
or do I have to create my own class to accommodate the above?


TIA
Zwi,
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Dictionary objet

Zwi,

I don't think so, you will need to code it yourself.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Zwi" wrote in message
...
Hi all,

I wish to use the Dictionary object but with some modifications as

follows:

At the "Add method" to have a third option to sum up the frequency of
that "key".

At the "Remove method" do remove the item if that third key above has
frequency of 1, otherwise reduce that key by 1.

Is this possible?
or do I have to create my own class to accommodate the above?


TIA
Zwi,



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Dictionary objet

Zwi wrote in message ...

I wish to use the Dictionary object but with some modifications as follows:

At the "Add method" to have a third option to sum up the frequency of
that "key".

At the "Remove method" do remove the item if that third key above has
frequency of 1, otherwise reduce that key by 1.

Is this possible?
or do I have to create my own class to accommodate the above?


The Dictionary object is part of the Microsoft Scripting Runtime,
which is a compiled DLL. You'd need access to the (presumably C++)
source code to change its interface, all of which sounds like rather
more work than your second option!

I'd suggest you create, in fact, two new classes, one to extend the
functionality of Dictionary, ReferenceCountedDictionary, say (!) and
ReferenceCountedItem.

So you might have (I'm typing this off the top of my head, no
guarantees as to perfection!)

Class ReferenceCountedDictionary:

Private dict As Dictionary

Public Sub Add(key, newobject)

dim o as ReferenceCountedItem

If dict.Exists(key) Then
dict.Item(key).IncrementCount
Else
Set o = New ReferenceCountedItem
set o.Obj = newobject
End If

End Sub

Public Sub Remove(key)
If dict.Exists(key) Then
If dict.Item(key).Count = 1 Then
dict.Remove key
Else
dict.Item(key).DecrementCount
End If
End If
End Sub

.... and Class ReferenceCountedItem:

Public Count As Long ' you might prefer to use Private declarations
and
Public Obj As Object ' access them via Properties...

Public Sub IncrementCount
Count = Count + 1
End Sub

Public Sub DecrementCount
Count = Count - 1
End Sub

Private SUb Class_Initialize
Count=1
End Sub

.... I hope that gives an idea of how you might accomplish it!
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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
Customizing a dictionary Grant Excel Worksheet Functions 3 September 10th 09 01:22 PM
Excel Function Dictionary v3 Peter Noneley Excel Discussion (Misc queries) 5 December 5th 08 05:56 PM
"Excel Function Dictionary" new URL? Markus L Excel Worksheet Functions 1 February 19th 05 05:02 PM
How to remove a word from dictionary? robmirabile Excel Discussion (Misc queries) 7 December 8th 04 06:39 PM
VBA Excel objet indexed mor.mic Excel Programming 2 September 23rd 03 06:29 PM


All times are GMT +1. The time now is 11:55 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"