|
-
Jun 11th, 2007, 05:05 AM
#1
Thread Starter
New Member
Module problem
Hi,
In my application I have:
1 MDI (MDIParent1)
2 Forms (frm1 and frm2)
1 Module (module1)
In MDIParent1 I have the foolowing code:
Sub New()
InitializeComponent()
Dim f1 As New frm1: f1.MdiParent = Me : f1.Close()
Dim f2 As New frm2: f2.MdiParent = Me : f2.Close()
end sub
I would like to init module1 too like I done for frm1 and frm2 because when
I am calling a function that is in the module I get an error:
"The type initializer for 'ApplicationName.Module1' threw an exception."
In addition (in the add watch during debug):
"reference to a non-shared member requires an object"
Please help
Eric H.
-
Jun 11th, 2007, 05:10 AM
#2
Re: Module problem
Could you show what line of code that caused that error?
-
Jun 11th, 2007, 05:13 AM
#3
Re: Module problem
does your code error in the InitializeComponent sub? If so can you post the code for this? and where it dies?
After setting the parent, why do you close the forms?
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
-
Jun 11th, 2007, 06:21 AM
#4
Thread Starter
New Member
Re: Module problem
Hello,
Thanks for your replies.
I do not have any InitializeComponents function, It is the default one.
The problem is that I am calling to a function that is in the module1 and in this function I am using an ADODB Connection object that is declared in this module.
If I am declaring the ADODB connection to the MDIParent1 and I am writing the function into the MDIParent1, no problem occurred.
SO I presume that the problem is that the I have to init the module1 in the Sub New of the MDIParent1 as I done for frm1 and frm2.
I hope you understand because english is not my mother tongue and VB.NET is new for me.
Thanks
-
Jun 11th, 2007, 06:26 AM
#5
Fanatic Member
Re: Module problem
a module doesn't need to be initialize. It only contains function that are common to different class in your project.
I assume that your connection is to be used every where in your program, instead of defining in form 1, you can as well do all your database interaction in the module and just return the result to the forms.
-
Jun 11th, 2007, 07:52 AM
#6
Thread Starter
New Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|