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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form.Show = Out of Memory

Status
Not open for further replies.

sparrow

Programmer
Jun 14, 1999
35
HK
I have a VB5 application, recently installed on several PC's. On some of the PC's, when the user tries to open a child form they get the error message &quot;Run-time error 7. Out of memory&quot;.<br>
<br>
I have tracjed it doen to the form.show command, but I can see no reason for getting this error.<br>
<br>
Running under NT4 SP3<br>
Memory usage 75000 out of 259000<br>
64Meg machine with 200Meg paging File<br>
<br>
If anyone has any ideas of what I can look for then please help me.<br>
<br>
<br>
Paul
 
The error can occur when you exceed the allowable number of controls for a project. The painful way to resolve the problem is to start removing any form, label, image, text box, etc. that isn't essential to function. You might try placing individual controls in a control array and load them when they are needed. The error will usually go away. The REALLY painful way to fix the problem is to scratch your head, compact the code, add more RAM and then wonder why a 128MB machine doesn't have enough memory to load a simple form.<br>
You can search the Microsoft web-site for maximum allowable controls but I'm pretty sure it's 255 (a number I've accidentally exceeded from time to time).<br>
Regards,<br>
Alt255
 
I <b>used/<b> to have this problem all the time, when we used Windows for Workgroups, but since moving to NT (Citrix WInframe actually) the problem has gone away.<br>
<br>
We've got several &quot;large&quot; applications out there now and I'm a bit surprised that the limitation of 255 controls is per <b>application[b/] - are you sure Alt255?<br>
<br>
Mike <p>Mike Lacey<br><a href=mailto:Mike_Lacey@Cargill.Com>Mike_Lacey@Cargill.Com</a><br><a href= > </a><br>
 
Read it in the Microsoft docs. Never really believed it. As I said, I went over the limit a few times (problems under VB2.0 but none under 6.0, so far). I'll try to dig it up and post it.
 
Thanks for the information. I will check it out.<br>
What I forgot to say was that the program does not fail on all PC's that it has been installed to.<br>
It works fine on my development machine, and 3 out of 4 user machines in Hong Kong, but fails on my personal PC, 1 user PC in Hong KOng, and 1 PC in Singapore.<br>
<br>
This made me think it was something to do with PC configurations (Page file of NT service packs) but I can not find a common cause. <br>

 
As usual, my head is buried so deeply, if I opened my I eyes I would have a clear view of my prostate.<br>
The 255 control limit applies to a form, not a project. Microsoft states, in Visual Basic Version 6.0 Frequently Asked Questions; &quot;Microsoft Visual Basic 6.0 will allow a total of 255 controls on a form.&quot;<br>
I decided to verify the information so I placed 667 buttons on a form (all that I could fit), saved the form (good save), ran the project (good run), compiled the project (good compile) and ran the executable (another good run).<br>
I was very wrong, but not as wrong as the VB 6.0 FAQ.<br>
Next time, I think I'll taste my foot before I try to swallow it.<br>
Sorry about the bad post.
 
Thanks for the posts.<br>
I took your advice anyway and started checking out the controls.<br>
I found the problem to be the RichTextBox on the form.<br>
Reinstated RichText32.OCX, but that didnt help, so I replaced the RichTextBox with a normal TextBox.<br>
Program seems to run OK at all locations now.<br>
<br>
Guess I never will know the cause of the problem, NT?? , other software ??, but at least the users are happy<br>
<br>
<br>
Paul
 
FYI - I started running into problems at about 850 textboxes or more.
 
Not the first time I've heard about RichText32.OCX causing problems.<br>
<br>
Mike<br>
<p>Mike Lacey<br><a href=mailto:Mike_Lacey@Cargill.Com>Mike_Lacey@Cargill.Com</a><br><a href= > </a><br>
 
The limitation of 255 controls is per form and not per project. I have over 325 controls on one form but put most of them in arrays so I can go past the limit
 
Hi all,
What MS said in VB 6.0 FAQs - &quot;255 max control in a form&quot;, could it means if they are not control array? On the other words, if we're placing control in array we can exceed 255.

Alt255: when you put 667 buttons in a form, did you put them in array?
 
Yes. Too busy to create 667 unique controls (LOL). That was the source of my misunderstanding. I believe the limit for elements in a control array is 32767. (But don't trust that number. I haven't been right even once in this thread.)

I should've shut up a long time ago. :)

Alt255@Vorpalcom.Intranets.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top