473,320 Members | 1,990 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Run Time Error 6 - Overflow. Please help!

I have this code for downloading .zip files from an FTP site. The download works perfectly... unless the file is over 100,000kb (it seems). If it is, I get the "Overflow" error.

Does anyone see anything wrong with the following code? (There's also a class module that goes with this code, which I can post as well... but I figured I would start with this module first.)

Expand|Select|Wrap|Line Numbers
  1. Private Sub TestFTPDOWNload_Click()
  2. On Error GoTo ErrHandler
  3.  
  4. Dim objFTP As FTP
  5. Const conTARGET = "MyFTPAddress/70992.zip"
  6.  
  7.  
  8.  
  9.  
  10.   Set objFTP = New FTP
  11.   With objFTP
  12.     .FtpURL = conTARGET
  13.     .DestinationFile = "C:\Users\LIB4IA1\Desktop\test3.zip"
  14.     .AutoCreateRemoteDir = False
  15.     If Not .IsConnected Then .DialDefaultNumber
  16.     .ConnectToFTPHost "UserName", "Password"
  17.     .WriteFTPDataToFile
  18.   End With
  19. ExitHere:
  20.   On Error Resume Next
  21.   Set objFTP = Nothing
  22.   Call SysCmd(acSysCmdRemoveMeter)
  23.   Exit Sub
  24. ErrHandler:
  25.   MsgBox Err.Number & vbCrLf & Err.Description, _
  26.        vbCritical + vbOKOnly, Err.Source
  27.   Resume ExitHere
  28.  
  29. End Sub
Nov 3 '15 #1

✓ answered by Rabbit

The most likely cause is the cint on line 10. You're converting something to an integer and an integer doesn't hold a large range of values.

7 1723
Rabbit
12,516 Expert Mod 8TB
Please use code tags when posting code or formatted data.

You haven't told us what line it is erroring on but it's probably at WriteFTPDataToFile, so you need to look at the code within that function.
Nov 4 '15 #2
Sorry about that! I'm new here, but I should have looked over the guidelines.

I'm thinking it's this chunk of code that's erroring out (I'm stepping through the code now to pinpoint it, but it's taking forever). It loops through this chunk over and over and over, while it's downloading the file:



Expand|Select|Wrap|Line Numbers
  1.   Do
  2.     ReDim abytData(MAX_CHUNK)
  3.     lngRet = apiInetReadFile(hFTP, _
  4.               abytData(0), _
  5.               MAX_CHUNK, _
  6.               lngBytesRead)
  7.     Call apiWriteFile(hFile, abytData(0), MAX_CHUNK, _
  8.               lngBytesWritten, 0&)
  9.     lngTotalBytesWritten = lngTotalBytesWritten + lngBytesWritten
  10.     Call SysCmd(acSysCmdUpdateMeter, CInt(lngTotalBytesWritten / mlngSize))
  11.   Loop Until lngRet <> 0 And lngBytesRead = 0
Nov 4 '15 #3
Rabbit
12,516 Expert Mod 8TB
The most likely cause is the cint on line 10. You're converting something to an integer and an integer doesn't hold a large range of values.
Nov 4 '15 #4
Ah. Makes sense. Can I change that to a Long, or something? This is code that I borrowed from here and there, so I'm completely unfamiliar with these commands in that chunk of code. I'm not even sure what a "c"int is, compared to an int - integer.

Would you think I could flip it to Long? Or cLong lol

EDIT: Looks like it would be CLng?

THanks for the help :)
Nov 5 '15 #5
Rabbit
12,516 Expert Mod 8TB
Glad I could help. Were you able to confirm that it worked?

On a side note, the cint function Converts an object into an integer, hence the c.
Nov 5 '15 #6
It did work! But now I have another issue.

As you can see in the code, the "conTRAGET" wants to know the name of the file that I wish to download.

There's one issue: Everything after the "HM_PROD_CSV_PARTIAL_2015116", and before the ".zip", is some kind of strange timestamp, that will always be different, each time they load this file onto the FTP server. I tried using a wild card, like "ftp://ftp.myjob.com/MAP_Outbound/HM_PROD_CSV_PARTIAL*.zip", but it doesn't like it.

Can you think of any way to use a wildcard here?

Expand|Select|Wrap|Line Numbers
  1. conTARGET = "ftp://ftp.myjob.com/MAP_Outbound/HM_PROD_CSV_PARTIAL_201511604041401.zip"                 
  2.   Set objFTP = New FTP
  3.   With objFTP
  4.     .FtpURL = conTARGET  
Nov 6 '15 #7
zmbd
5,501 Expert Mod 4TB
jimswork1341 - please start a new thread for a new question.
thnx
=z=
Nov 7 '15 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: MyndPhlyp | last post by:
I am about to completely lose what is left of my poor mynd! The historical dissertation gets rather verbose, so I hope you can wade through it all. I really need some help on this one or I'm...
4
by: Christaaay | last post by:
I have been using the code below successfully for almost a year. yesterday, I began getting a run time error 6 (overflow). I am using the code in an Access 2000 database. Can anyone help me...
3
by: C. Sengstock | last post by:
Hi, i´ve got an iteration with random generated floating point numbers. During the iteration process sometimes the programm stops with the error: "floating point error: overflow" Is the...
4
by: Chua Wen Ching | last post by:
Thanks Derek... Okay i had another question.. my program runs smoothly for the first minute, after 1 minute... suddenly it breaks and display this error: do you know what is the cause of...
1
by: Steve Fraser | last post by:
I am wondering if anyone can help me out. I have an Access Database that has been running since forever. Now when I try to open a form I get the "Run-time error '6' Overflow message and a window...
0
by: krakesh11 | last post by:
Hi , In my sas program , I am facing a problem of overflow error in one of my SAS programs . Kindly help me in gettingresolve this issue . The exact error message which I got is : "ERROR:...
3
by: Yamasassy | last post by:
Hi im having even more problems i have run time error 9 Subscript out of range i can just use print #1 txtFullname.Text but i think this is wrong for my assignemt as i supposed ot use a...
0
by: strpradeep | last post by:
hello everyone.. i am new to vb6 and i am developing a small application using excel to create an instance of excel. the following code gives me the run time error. please help me.. Private Sub...
7
by: Amy Badgett | last post by:
I have been getting this error: "object doesn't support this object or method." The debug is saying the problem is in the series of if statements based on which product I enter in the...
18
by: W4FF | last post by:
I'm having issues with Access 2010, the interface includes the following input options:Last Name, First Name, SSN, and Birth date. Access was working great since 2012 and all of a sudden we are...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.