![]() |
|
#9
|
||||
|
||||
|
Actually, that's exactly how I'd describe a method: a function written by a programmer (or programming team), but for that object and for no other. That's where my assumptions used to lead me astray. For example: I had learned of a "method" (which I thought of as a VBA function) that I could use to determine whether a certain item exists in a Dictionary object:
Code:
Set od = CreateObject("Scripting.Dictionary")
' ...populate the Dictionary, then
If Not od.Exists("History") Then Abend "Missing History key."
Code:
If Not ThisWorkbook.Worksheets.Exists("MySheet") Then...
For years that drove me crazy. Why could I use the Exists function one time and not another?! It wasn't until later—not until I finally wrote my own object, in fact—that I saw, very simply, that Exists was not a function of the VBA language, nor even a function of the Excel application, but a function of the Dictionary object. The folks who created the Dictionary object wrote an Exists method into it; but the folks who wrote the Worksheets collection in Excel did not—and a method exists only in the object it's written for. Likewise, when you're adding an item to most Collections, the first argument for the Add method is the item you're adding and the second item is the optional key. But in a Dictionary's Add method, the first argument is the required key and the second is the contents. Different objects, different rules. Different subroutines, in fact, despite the fact that they have the same name. It's my understanding that this is common to object-oriented programming, not specific to one language or environment or another. If this VFP thingy (is that Visual FoxPro?) had a great deal of consistency in the methods between various objects, it's probably because the architects decided to maintain an overall design philosophy rather than let each item be constructed from scratch. I don't usually let it bother me, now. When I decided I wanted an Exists method for Collections, I went ahead and wrote it as a function and use it all the time, now. |
| Tags |
| range, sort, vba |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Outlook Combobox Sort Code | lms | Outlook | 1 | 09-18-2013 09:56 AM |
How to Sort Table Cells from Left to Right
|
tamaracklodge | Word Tables | 4 | 03-04-2013 04:00 AM |
| Sort table using macro | saslotteroy | Word VBA | 2 | 09-15-2011 02:41 PM |
How to sort table having three columns?
|
Bahir Barak | Word | 2 | 01-20-2011 01:52 PM |
| Can I sort a Pivot table by subtotals? | oshkosh | Excel | 1 | 12-07-2010 06:20 PM |