Rick FlyFish
Rick FlyFish

Reputation: 105

VB in Visual Studio Adding a class module will it have access for the form.vb I've built?

Hello thanks for reading my question, I've build a user form with controls to control equipment via RS232 and USB. I've also added a separate class module "class.vb" to hold miscellaneous functions like writing to an ini file.

When I'm in the code section of the Form.vb and I type txb for text boxes that I have in the form visual studio pops up a nice list of all things in the form that start with txb.

However, when I do the same thing in my class.vb it does not do this and even if I type the whole thing such as txbModulation and then add the dot after it does not come up with the list of properties.

Does the class.vb have access to Form1.vb controls?

Upvotes: 1

Views: 433

Answers (1)

Idle_Mind
Idle_Mind

Reputation: 39122

When I'm in the code section of the Form.vb and I type txb for text boxes that I have in the form visual studio pops up a nice list of all things in the form that start with txb.

This is because when you start typing a variable name, Visual Studio starts looking for a match. It looks in block scope first (a for or while loop maybe), then at local (function/sub) scope, and finally at class level (a form is a class). It will also look for any matches in Modules if you have them. See Scope in Visual Basic for more info.

Since the Form and your INI Class are different, they cannot see each other unless you pass references or somehow pass values via parameters to subs/functions.

Upvotes: 1

Related Questions