Re: Countif in VB Script

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Dolemite,

Glad to hear you got it working. A collection can be very useful.
One way to think about it is to consider how a hospital
identifies/keeps track of its patients.
They could do it by the appearance the patient (age,gender, color) etc.
However, they use a wrist band identifier, which is usually not subject
to interpretation.

A collection is a storage device that can hold almost anything from
objects, strings, numbers to even other collections (The Item).

The collection keeps track what it has stored by using a unique string
identifier for each item (The Key). Only one unique Key is allowed,
so you get an error if you try to duplicate it.

In the example, I provided, every item stored was an empty string,
but each key was unique. There is no need to load up a collection
with other than empty strings unless you have to access the items later.

You will see code samples such as...
colThings.Add Cstr(Range("Al").Value), Cstr(Range("A1").Value)

But if you are only checking for duplicates, what you put in the
item slot makes no difference.

Regards,
Jim Cone
San Francisco, USA



"Dolemite"
<Dolemite.1uowio_1125594330.2488@xxxxxxxxxxxxxxxxxxxxx>
wrote in message
news:Dolemite.1uowio_1125594330.2488@xxxxxxxxxxxxxxxxxxxxx
Thank you for the response! It took a little bit of playing around to
figure out how that was actually working...and I can't say that I am
entirely sure...but it is working and working well.
Could you enlighten me as to how & why this statement actually works:
colvalues.add vbNullString, CStr(Range("a1").value)
add(item, [key], [before], [after])

I just am not getting it....
obviously the vbNullString is the item and the value (as a string) of
A1 is the key
but I can't find any simple explanation of why this works. Why
vbNullString? Or better yet, could you explain to me the item & key.
And thanks again for the code, it does work great!
--
Dolemite

.



Relevant Pages

  • Double Linked List Help
    ... 256 characters long identified in the input file F. Each identifier ... identifier, length is an integer representing the length of the ... string is a string of characters representing the identifier itself. ...
    (comp.lang.c.moderated)
  • Re: kde4 and opengl
    ... server glx vendor string: NVIDIA Corporation ... Identifier "Simple Layout" ...
    (comp.windows.x.kde)
  • IDispatchEx functionality for COM interoperable .NET objects
    ... >> var mystring = child.xml ... > except that, using a string rather than an identifier, the latter syntax ... > need to code Invoke to recognize these special DISPIDs and redirect to a ...
    (microsoft.public.dotnet.framework.interop)
  • Re: COM Collections/arrays accessed from JScript
    ... >> var mystring = child.xml ... > except that, using a string rather than an identifier, the latter syntax ... > need to code Invoke to recognize these special DISPIDs and redirect to a ...
    (microsoft.public.win32.programmer.ole)