1

I'm working on a project in VB6. I have to add a download functionality. It contains 1 form, 1 class module and 1 module (bas) files. When I add the existing module to my project, it is successful But when I try to add the class module or the frm file to the project, it says OUT OF MEMORY. I have been banging my head against this issue for quite some time now but couldn't find any solution.

I cannot post any code because it's a company project. All I can tell is that its a huge project with thousands of lines of code. The module I'm trying to add is used to download a file over HTTP, and it accesses the methods in Wininet.dll.

I don't know if the project has reached it maximum limit of lines of code, or whether it's an issue of variables.

I have heard that making a DLL can solve this issue, but we don't need that. Can anyone help?

5
  • 1
    Have you tried copy and paste into an existing (empty) module file? Commented Apr 30, 2014 at 15:25
  • So what you're saying is that this project (with one form, one class module and one BAS module) formerly worked? So which file are you referring to when you say "the existing module"? And which project are you referring to when you say "my project"? Finally, are you serious saying that the entire application with thousands of lines of code is in three files? That's unusual. You could probably help things but breaking the code down into smaller files. Commented May 1, 2014 at 0:03
  • @Mark Bertenshaw you'd be surprised. There is some horrible code at my company. Several vb6 programs that run on schedules that launches the program which displays a form with a timer in it that calls methods in a single bas file containing thousands of lines of code... Sometimes in one function. They had to branch some of these projects to add functionality for certain edge cases because vb6 wouldn't allow any more lines of code (removing the lines that didn't apply to the edge cases) such things exist, they make me cry Commented May 1, 2014 at 0:07
  • I appreciate that this is a bad situation, but what I am trying to get you to say is "what action stopped your code from running?". The top answer has good advice, but it concerns me that you need to provide more (tedious!) detail. Since you haven't chosen an answer, it seems that you are not satisfied yet. Commented May 1, 2014 at 8:18
  • 1
    I suppose that what I am trying to get you to do is to provide a step by step reproduction case for this bug. It is a bit ambiguous so far exactly at what point you get the Out of Memory error. Doing a file operation in the IDE or at run-time? Please edit the original post with as much detail as possible. Commented May 1, 2014 at 8:29

2 Answers 2

5

I think I've faced something similar in the past, and after some digging and trying different things it turned out to be the number of variables / forms / controls that we had in the project. There is a limit to the number of unique variable, constant, and control names you can have in the project.

The way we proved it was to add the module that didn't quite break it, then add an empty module. In the empty module start adding variables until it breaks, it shouldn't take to long.

We cured it by going through the code and changing names of labels on forms to be control arrays, using constants for strings, and removing any code that was old an no longer required. Try to remove unused variables as well.

If it makes life easier you could try moving some of the code out to dll's. Hope this helps.

Cast your eye over this, the sub sections might help: VB6 Project Limitations

Sign up to request clarification or add additional context in comments.

2 Comments

The experimental approach of adding declarations until it breaks is the only one which makes any practical sense.
Yeah we figured this one out too... probably is the same thing as you have explained... thanks a lot for the reply though...
-2

You know there are high level objects available that do in two or three lines what requires many in Wininet.

Try this way using xmlhttp. Edit the url's etc. If it seems to work comment out the if / end if to dump info even if seeming to work. It's vbscript but vbscript works in vb6.

 On Error Resume Next
 Set File = WScript.CreateObject("Microsoft.XMLHTTP")
 File.Open "GET", "http://www.microsoft.com/en-au/default.aspx", False
 'This is IE 8 headers
 File.setRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 1.1.4322; .NET CLR 3.5.30729; .NET CLR 3.0.30618; .NET4.0C; .NET4.0E; BCD2000; BCD2000)"
 File.Send
 If err.number <> 0 then 
    line =""
    Line  = Line &  vbcrlf & "" 
    Line  = Line &  vbcrlf & "Error getting file" 
    Line  = Line &  vbcrlf & "==================" 
    Line  = Line &  vbcrlf & "" 
    Line  = Line &  vbcrlf & "Error " & err.number & "(0x" & hex(err.number) & ") " & err.description 
    Line  = Line &  vbcrlf & "Source " & err.source 
    Line  = Line &  vbcrlf & "" 
    Line  = Line &  vbcrlf & "HTTP Error " & File.Status & " " & File.StatusText
    Line  = Line &  vbcrlf &  File.getAllResponseHeaders
    wscript.echo Line
    Err.clear
    wscript.quit
 End If

On Error Goto 0

 Set BS = CreateObject("ADODB.Stream")
 BS.type = 1
 BS.open
 BS.Write File.ResponseBody
 BS.SaveToFile "c:\users\test.txt", 2

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.