Home All Groups Group Topic Archive Search About

Question about a conversion project

Author
24 May 2006 1:20 PM
Kyjan
Greetings to all!

I chose to post this here because I'm trying to convert a project that
was written back in the day in VB6 and I have a question about syntax
that I've never seen before.

There are multiple forms.  One form A, it access something on form B by
using the following syntax:

formB!btnInfo.Caption

What is the purpose of the "!" character?  Why isn't the "." character
used instead?

Thanks,

Kyjan

Author
24 May 2006 1:43 PM
Chris
Kyjan wrote:
Show quoteHide quote
> Greetings to all!
>
> I chose to post this here because I'm trying to convert a project that
> was written back in the day in VB6 and I have a question about syntax
> that I've never seen before.
>
> There are multiple forms.  One form A, it access something on form B by
> using the following syntax:
>
> formB!btnInfo.Caption
>
> What is the purpose of the "!" character?  Why isn't the "." character
> used instead?
>
> Thanks,
>
> Kyjan
>


It's just VB6 way to access the instance of formB.  VB6 wasn't really OOP.

Chris
Author
24 May 2006 2:10 PM
Herfried K. Wagner [MVP]
Show quote Hide quote
"Chris" <no@spam.com> schrieb:
>> I chose to post this here because I'm trying to convert a project that
>> was written back in the day in VB6 and I have a question about syntax
>> that I've never seen before.
>>
>> There are multiple forms.  One form A, it access something on form B by
>> using the following syntax:
>>
>> formB!btnInfo.Caption
>>
>> What is the purpose of the "!" character?  Why isn't the "." character
>> used instead?
>
> It's just VB6 way to access the instance of formB.  VB6 wasn't really OOP.

Not really.  '!' was and is used to access keyed collections.  Sample:

\\\
Dim c As Collection
Set c = New Collection
Call c.Add("Hello", "Key1")
Call c.Add("World", "Key2")

Call MsgBox(c!Key2)
Call MsgBox(c.Item("Key2"))
Call MsgBox(c("Key2"))
///

The last three lines are semantically equivalent.  In the OP's sample the
form's 'Controls' collection is accessed.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
31 May 2006 1:03 PM
Kyjan
So it was basically used to access the default property (in .NET terms)
of an object?

Thank you guys for the reply!