470,620 Members | 1,792 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,620 developers. It's quick & easy.

Module Control Addressing in VB.Net

Good evening all,

I am going crazy with a problem that I am sure has a simple solution.

I need to add items to a ComboBox on a Form. I can do it simply when I
code on form.vb, but when go to a procedure on a seperate module it says
"Name 'ComboBox' is not declared". I have tried setting the modifiers
for the ComboBox to Public, Friend and Private all to no avail. I am
also not sure why on the main page "Me." is used before a control, I
tried this on the module but it didn't work.

Any help you may be able to provide would be much appreciated as I am
still trying to learn this language.

Yours sincerely,

Brent McIntyre

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #1
3 3628
Hello,

"Brent McIntyre" <br************@aep.salvationarmy.org> schrieb:
I am going crazy with a problem that I am sure has a simple
solution.

I need to add items to a ComboBox on a Form. I can
do it simply when I code on form.vb, but when go to
a procedure on a seperate module it says "Name
'ComboBox' is not declared".


You must pass a reference to the control, for example in a parameter:

\\\
Imports System.Windows.Forms

Public Module MyModule
Public Sub Bla(ByVal Foo As ComboBox)
Foo.Items.Add(...)
End Sub
End Module
///

Usage (in the form):

\\\
MyModule.Bla(Me.ComboBox1)
///

--
Herfried K. Wagner
MVP ∑ VB Classic, VB.NET
http://www.mvps.org/dotnet
Nov 20 '05 #2
OOP is a bitch sometimes. Herfried is exactly right. You really have
to watch that cause variables are objects aswell.

The only thing I've never figured out is in an MDI environment, how to
reference one child from another LOL

Just remember, everything's an object and all objects have to be
referenced/declared somewhere somehow :)

Tibby
"Brent McIntyre" <br************@aep.salvationarmy.org> wrote in message
news:O3**************@TK2MSFTNGP10.phx.gbl...
Good evening all,

I am going crazy with a problem that I am sure has a simple solution.

I need to add items to a ComboBox on a Form. I can do it simply when I
code on form.vb, but when go to a procedure on a seperate module it says
"Name 'ComboBox' is not declared". I have tried setting the modifiers
for the ComboBox to Public, Friend and Private all to no avail. I am
also not sure why on the main page "Me." is used before a control, I
tried this on the module but it didn't work.

Any help you may be able to provide would be much appreciated as I am
still trying to learn this language.

Yours sincerely,

Brent McIntyre

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 20 '05 #3
"Brent McIntyre" <br************@aep.salvationarmy.org> schrieb
I am going crazy with a problem that I am sure has a simple
solution.

I need to add items to a ComboBox on a Form. I can do it simply when
I code on form.vb, but when go to a procedure on a seperate module it
says "Name 'ComboBox' is not declared". I have tried setting the
modifiers for the ComboBox to Public, Friend and Private all to no
avail. I am also not sure why on the main page "Me." is used before
a control, I tried this on the module but it didn't work.

Any help you may be able to provide would be much appreciated as I
am still trying to learn this language.


The Combobox is a property of the Form. If you want to access a property of
an object, you need a reference to the object. If you don't have a reference
you have to pass it to the Module.
--
Armin

Nov 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Kenneth McDonald | last post: by
11 posts views Thread by Tony Williams | last post: by
6 posts views Thread by Valerie Hough | last post: by
reply views Thread by Stefan Lischke | last post: by
1 post views Thread by =?Utf-8?B?dWx0cmFuZXQ=?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.