Question about a conversion project

  • Thread starter Thread starter Kyjan
  • Start date Start date
K

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
 
Kyjan said:
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
 
Chris said:
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.
 
So it was basically used to access the default property (in .NET terms)
of an object?

Thank you guys for the reply!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top