Question

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?

Was it helpful?

Solution

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

OTHER TIPS

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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top