Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Function in module creates new instance of form

Status
Not open for further replies.

Sorwen

Technical User
Nov 30, 2002
1,641
US
I've never had this before and I wanted to see if any knew what might be happening. I have a form and in the code there is a public function that is called which sends text to a label on the form making sure to do so in the thread for the form. I have a function in a module and in that function it calls to the forms function so the user gets a message of what it is working on at the time. I've used this code before in other programs and have done similar things before as well. Here is the funny part for some reason rather than using the function on the current form it some how creates a whole new instance of the form instead. I've never seen that happen before. I got around this by asking the application for the open from and setting it as an object.

The call before was simply:
main_frm.sMessage("Working")

The new is:
Dim frm As Object = Application.OpenForms.Item("main_frm")
frm.sMessage("Working")

Any ideas what I could be missing that would cause a simple call to a function instead create a whole new instance?

-I hate Microsoft!
-Forever and always forward.
-My kingdom for a edit button!
 

Search in your code for "New main_frm".


I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day!
 
Nope, there isn't one. That is the thing I can't think of any reason it could do it. None the less the, the very first thing it does once it hits that main_frm.sMessage line is to create a new instance.

-I hate Microsoft!
-Forever and always forward.
-My kingdom for a edit button!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top