Solved

VB6 control limit error deleted all menus

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VB 6 error 5 in windows 10 but not in XP 7 64
Advice in Xamarin 21 97
IF ELSE Statement in Excel Macro VBA 16 75
Export Data to Different .csv Files 26 115
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

820 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