Solved

VB6 control limit error deleted all menus

Posted on 2012-12-31
5
555 Views
Last Modified: 2013-01-06
I tried to add 4 menu items and on OK it gave me the error that I had reached the form's control limit and that I needed to delete some controls.  So I hit Cancel to undo the menu changes.  

However on Run I got errors... turns out all the menus are gone... not just the changes I made.

How do I recover????
0
Comment
Question by:torrid333
  • 3
5 Comments
 
LVL 46

Assisted Solution

by:Martin Liss
Martin Liss earned 250 total points
ID: 38733714
Unless you have backed up, you don't unfortunately.

You may be aware of this but if this is VB6 then you can get around the 256 (255?) control limit by changing individual controls into control arrays. Start with un-referred to labels as they are the easiest.
0
 
LVL 46

Expert Comment

by:Martin Liss
ID: 38733716
I should have said above that control arrays count as just one control as far as the limit goes. Also I would think that the code, if any, for the menu items would still be there.
0
 
LVL 15

Accepted Solution

by:
eemit earned 250 total points
ID: 38738531
There is a fixed limit of 254 control names per form
Here are three ways to work around the control name and system resource limitations:

Use a control array - instead of using several instances of a control in a form, create a control array for all the similar controls on the form. Members of a control array share the same control name.

Dynamically create the controls as required - instead of loading all the controls on a form when you first display the form, try loading the controls as needed.

Put your controls on a UserControl - similar to using a control array, you can create a UserControl that contains your controls and then add the UserControl to your project. For example, if you need a form that displays 500 text boxes, create a UserControl that contains 250 text boxes, and put two instances of your UserControl on the form. You now have 500 text boxes on the form, but only two controls.

References
http://support.microsoft.com/kb/229756/en-us
0
 

Author Closing Comment

by:torrid333
ID: 38745082
I recovered from a backup file using a tool called winmerge which lets you compare two files side by side... kind of like diff in unix.

I will have to work on changing some stuff to control arrays but for now just wanted to recover back to where I was....
0
 
LVL 46

Expert Comment

by:Martin Liss
ID: 38745194
You're welcome and I'm glad I was able to help. The same thing happened to me along time ago in a place far, far, away.

Marty - MVP 2009 to 2012
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

895 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now