473,399 Members | 2,146 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Need Help Checking MdiParent on Form Open event from a module

Hi

Whenever I open a form and want to check for an existence of the form
I use the following code:

Dim frm As Form
For Each frm In Me.MdiParent.MdiChildren
If TypeOf frm Is Form17 Then
frm.Close()
End If
Next

However when this same code is placed in a module it does not work as
'Me' throws an error:
Me is not valid withing a module.

How do I overcome this?

Thanks in advance.
Jun 27 '08 #1
3 1456
"The Mad Ape" <ch******@gmail.comschrieb
Hi

Whenever I open a form and want to check for an existence of the
form I use the following code:

Dim frm As Form
For Each frm In Me.MdiParent.MdiChildren
If TypeOf frm Is Form17 Then
frm.Close()
End If
Next

However when this same code is placed in a module it does not work
as 'Me' throws an error:
Me is not valid withing a module.

How do I overcome this?
Get rid of the Module. Move the code into the MDIParent. If you need to
call it from outside, put it into a Public Sub. If there can be only one
instance of Form17, declare a variable of that type, so you won't have
to search for it.
Armin

Jun 27 '08 #2
On Apr 12, 11:28 am, "Armin Zingler" <az.nos...@freenet.dewrote:
"The Mad Ape" <chief...@gmail.comschrieb
Hi
Whenever I open a form and want to check for an existence of the
form I use the following code:
Dim frm As Form
For Each frm In Me.MdiParent.MdiChildren
If TypeOf frm Is Form17 Then
frm.Close()
End If
Next
However when this same code is placed in a module it does not work
as 'Me' throws an error:
Me is not valid withing a module.
How do I overcome this?

Get rid of the Module. Move the code into the MDIParent. If you need to
call it from outside, put it into a Public Sub. If there can be only one
instance of Form17, declare a variable of that type, so you won't have
to search for it.

Armin
I did what you said but now when I call it as follows:

AddHandler tabLblPulp.Click, AddressOf GetStandVol 'where GetStandVol
is the name of the sub and tabLblPulp is a programmatcially created
label that I wish to put code behind the click event.

I am getting and error that GetStandVol is not declared, even though I
declared it as a public sub in the parent form. What is up with that?

Thanks

Jun 27 '08 #3
On Apr 12, 11:38 am, The Mad Ape <chief...@gmail.comwrote:
On Apr 12, 11:28 am, "Armin Zingler" <az.nos...@freenet.dewrote:
"The Mad Ape" <chief...@gmail.comschrieb
Hi
Whenever I open a form and want to check for an existence of the
form I use the following code:
Dim frm As Form
For Each frm In Me.MdiParent.MdiChildren
If TypeOf frm Is Form17 Then
frm.Close()
End If
Next
However when this same code is placed in a module it does not work
as 'Me' throws an error:
Me is not valid withing a module.
How do I overcome this?
Get rid of the Module. Move the code into the MDIParent. If you need to
call it from outside, put it into a Public Sub. If there can be only one
instance of Form17, declare a variable of that type, so you won't have
to search for it.
Armin

I did what you said but now when I call it as follows:

AddHandler tabLblPulp.Click, AddressOf GetStandVol 'where GetStandVol
is the name of the sub and tabLblPulp is a programmatcially created
label that I wish to put code behind the click event.

I am getting and error that GetStandVol is not declared, even though I
declared it as a public sub in the parent form. What is up with that?

Thanks
Never mind. I just replaced AddressOf GetStandVol with AddressOf
Form1.GetStandVol where Form1 was the form that the Public resides.

Thanks
Jun 27 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Terrance | last post by:
I'm hoping that there's someone out here that can help me with a coding problem. Here is the scenerio: I have a MdiParent Form on this MdiParent form there is a listview control and several text...
2
by: Susan Bricker | last post by:
Greetings. Before I begin, I have been stuck on this problem for about a 5 days, now. I have tried and just seem to be not getting anywhere. I know that the explanation is lengthy, but I am a...
7
by: Jack Addington | last post by:
I've got a fairly simple application implementation that over time is going to get a lot bigger. I'm really trying to implement it in a way that will facilitate the growth. I am first writing a...
26
by: Paul Mars | last post by:
FormParent load opens FormChildA. FormChildA btn click opens FormChildB. (FormChildA and FormChildB are both children of FormParent) (FormChildA and FormChildB are different forms) Problem:...
4
by: Ben dotNet | last post by:
FormA is the mdiParent FormB is the child FormC is the Form that is used to open FormB How do I open FormB from FormC (that is not a child) so that it it's mdiParent is FormA? Thanks, --Ben
1
by: PDP-8E | last post by:
I'm new to VB.Net 2003 - (2 weeks in) so this MAY be straightforward... (Things changed since Octal Assembler I see !!!) I'll try to lay this out in a way that makes sense I created a...
4
by: zack | last post by:
Any help with this would be greatly appreciated, as cannot work out how to resolve. I have a report called "3_Strikes". In its 'On open' event is command to also open a criteria form popup form...
9
by: Tim | last post by:
I am new to this arena of development although I am hoping that some or most of my C# web development might carry through here as well. I have started to create a MDI application. I have the...
2
by: Thorgal | last post by:
Hello all I have 2 questions First: I'm trying to print a Listview from an mdichild but how can i address this listview. For example, FrmMain is my Main form. In this Main form I have...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.