Home > Archive > Visual Basic Syntax > April 2005 > VB syntax question - can you figure out what this does?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
VB syntax question - can you figure out what this does?
|
|
| Faisal Vali 2005-04-10, 4:01 pm |
| Hi all,
As will be evident from my question, I am fairly new to the VB
languages. My question is this:
Assume you've got a variable referring to some object, for e.g
Dim oServer
Set oServer = New CServer
What does this syntax really mean (this is a vbscript snippet):
oServer("Name")
Is the above accessing a property called "Name"?
Is it calling an overloaded function call operator in the oServer?
Any help, or direction towards helpful resources will help.
Thanks in advance,
Faisal Vali
| |
| Jeff Johnson [MVP: VB] 2005-04-10, 8:59 pm |
|
"Faisal Vali" <fvali@kumc.edu> wrote in message
news:Dqd6e.4666$sp3.1779@newsread3.news.atl.earthlink.net...
> As will be evident from my question, I am fairly new to the VB
> languages. My question is this:
>
> Assume you've got a variable referring to some object, for e.g
>
> Dim oServer
> Set oServer = New CServer
>
> What does this syntax really mean (this is a vbscript snippet):
>
> oServer("Name")
>
> Is the above accessing a property called "Name"?
> Is it calling an overloaded function call operator in the oServer?
As it stands it's not doing anything. For anything to be happening it should
look like one of these:
MyVariable = oServer("Name").SomeProperty
oServer("Name").SomeProperty = SomeValue
oServer("Name").SomeMethod [<parameters>]
What's happening is that class CServer has a default property (more than
likely it's the Item property) which exposes a collection. You can then pass
in the name or index of the desired member of the collection and get a
reference to it. In other words,
oServer("Name")
is a shortcut for
oServer.Item("Name")
|
|
|
|
|