Solved

VB6 control limit error deleted all menus

Posted on 2012-12-31
5
553 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 45

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 45

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 45

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

757 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

20 Experts available now in Live!

Get 1:1 Help Now