[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Error when using ME.Dispose closing a form

Posted on 2012-09-18
9
Medium Priority
?
587 Views
Last Modified: 2012-10-15
When I close a form and use Me.Close followed by Me.Dispose  It should return to another form, instead I get this error:

Unhandled exception has occurred in your application.  If you click continue the application will ignore this error and attempt to continue.  If you click quit the application will close immediately.

Collection was modified; enumeration operation may not execute.

It also mentioned something about:

Microsoft.VisualBasic.PowerPacks.ShapeCollecetion.Dispose

I use those for rectangles I have on the form.
0
Comment
Question by:NOTBOB90
  • 5
  • 4
9 Comments
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 38411809
Get rid of the "Me.Dispose()" call...
0
 

Author Comment

by:NOTBOB90
ID: 38413932
I need it because it the form gets re opened, the old data is still there.  I want to to open the form with the default values of the form.
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 38413956
Sounds like you're displaying the default instance of the form, such as:

    Form2.Show()

Instead, create a NEW instance each time:

    Dim F2 As New Form2
    F2.Show()

Now it will always be a new instance with the default values.

If this doesn't quite fit your scenario then please show your code that opens the form.
0
Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

 

Author Comment

by:NOTBOB90
ID: 38414160
I took out the me.dispose, and I still get this error after closing the form.  See attached.

I think it may have something to do with rectangle buttons I put on the form not unloading.
New-Wordpad-Document.doc
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 38414211
Hmmm...

Can you show how you declared and displayed the form?

Under what conditions and how are you closing the form?
0
 

Author Comment

by:NOTBOB90
ID: 38414714
frmMemberLookup.Show()

opens the form that is basically an onscreen keyboard so a person can lookup a name in a database.  Once the name is located and clicked on, the user clicks select user which returns the information back to the main screen.  The form is also closed in that select user button:

Me.close
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 38415137
Ok...it seems that my comment back here applies:
http://www.experts-exchange.com/Microsoft/Development/Q_27869534.html#a38413956

Is "frmMemberLookup" the name of the form?...or the name of a variable that is an instance of the form?

Most likely you need to change:

    frmMemberLookup.Show()

To:

    Dim lookup As New frmMemberLookup
    lookup.Show()
0
 

Accepted Solution

by:
NOTBOB90 earned 0 total points
ID: 38428487
This did not correct the error.  I ended up removing all of the rectangle objects manually and that seems to have fixed the error.  I am not sure why just dispoing the form does not do the same, but whatever.
0
 

Author Closing Comment

by:NOTBOB90
ID: 38496253
Because the solutons provided did not work
0

Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question