Lavos Posted September 23, 2016 Author Share Posted September 23, 2016 Seems like no one here doesn't have a decent vb6 updater to share anymore so I decided to make one. Hopefull this site still has some vb6 users lurking around to help me.What I'm trying to do is have a progress bar work upon downloading files from the web. I'm using Inet functions just so you know. https://gyazo.com/ca22e13e74a9903aed260cc50a490aa1I do have teamviewer if you're wondering, you could shoot me up a pm with your discord ID or skype if you want to go that route. A pseudo code would appreciated too! Link to comment Share on other sites More sharing options...
Slasheree Posted September 23, 2016 Share Posted September 23, 2016 First hit on google seems to do exactly what you need: [http://www.vbforums.com/showthread.php?311040-Download-File-Using-Inet-With-Progress-Bar](http://www.vbforums.com/showthread.php?311040-Download-File-Using-Inet-With-Progress-Bar)>! y u no google !? Link to comment Share on other sites More sharing options...
Lavos Posted September 23, 2016 Author Share Posted September 23, 2016 @'Slasheree':> First hit on google seems to do exactly what you need: [http://www.vbforums.com/showthread.php?311040-Download-File-Using-Inet-With-Progress-Bar](http://www.vbforums.com/showthread.php?311040-Download-File-Using-Inet-With-Progress-Bar)> > > >! y u no google !?I've googled that same exact link before. The thing is that that guy uses microsoftcontrols 5.0 where i decided to build mine from using shapes. It's far different than what I had in mind. Link to comment Share on other sites More sharing options...
Slasheree Posted September 23, 2016 Share Posted September 23, 2016 @'Lavos':> that guy uses microsoftcontrols 5.0 where i decided to build mine from using shapes.what do you mean by that ? the progress bars and such ? Link to comment Share on other sites More sharing options...
Lavos Posted September 24, 2016 Author Share Posted September 24, 2016 @'Slasheree':> @'Lavos':> > > that guy uses microsoftcontrols 5.0 where i decided to build mine from using shapes.> > what do you mean by that ? the progress bars and such ?im trying to use inet.getchuck function to work with the progression for a custom made progressbar. I'm hoping someone here would figure it out before I do. It seems all the programmers for eclipse have moved on to something else. Link to comment Share on other sites More sharing options...
Slasheree Posted September 24, 2016 Share Posted September 24, 2016 Then it's just like in that guys code, your "custom made progress bar" has to have a width property somewhere, all you have to do is:If you want current file progress then:onDownloadChuck(){.width = (Round((BytesReceivedOnThisChuckDownload / FileLength) * 100)) //to give value between 0-100}If you want whole download progress you'll have to check the full size of the download he needs and change FileLength to WholeThingLength Link to comment Share on other sites More sharing options...
Lavos Posted September 24, 2016 Author Share Posted September 24, 2016 @'Slasheree':> Then it's just like in that guys code, your "custom made progress bar" has to have a width property somewhere, all you have to do is:> > If you want current file progress then:> > onDownloadChuck(){> .width = (Round((BytesReceivedOnThisChuckDownload / FileLength) * 100)) //to give value between 0-100> }> > If you want whole download progress you'll have to check the full size of the download he needs and change FileLength to WholeThingLengthit looks like im having issues with getting inet.openurl() and inet.chunk() functions to work together, then i made this code for the chunk below:```Private Sub DownloadFile(ByVal URL As String, ByVal Filename As String) Dim FileBytes() As Byte Dim FileNum As Integer Dim BytesRecieved As Long Dim FileLength As Long Dim StrHeader As String Const CHUNK_SIZE As Long = 1024 DoEvents With frmMain.inetDownload .URL = URL .Execute , "GET", , "Range: Bytes=" & CStr(BytesRecieved) & "-" & vbCrLf While .StillExecuting DoEvents Wend End With StrHeader = frmMain.inetDownload.GetHeader("Content-Length") FileLength = Val(StrHeader) DoEvents BytesRecieved = 0 FileNum = FreeFile() Open Filename For Binary Access Write As #FileNum Do FileBytes() = frmMain.inetDownload.GetChunk(CHUNK_SIZE, icByteArray) Put #FileNum, , FileBytes() BytesRecieved = BytesRecieved + UBound(FileBytes, 1) + 1 DownloadProgress (Round((BytesRecieved / FileLength) * 100)) DoEvents Loop While UBound(FileBytes, 1) > 0 Close #FileNum Exit SubEnd SubPrivate Sub DownloadProgress(ByVal Percentage As String) frmMain.shpProgressfill.Width = PercentageEnd Sub```Its still a work in progress, i've never worked with inet before so i've been fiddling with things around it. Link to comment Share on other sites More sharing options...
Slasheree Posted September 24, 2016 Share Posted September 24, 2016 @'Lavos':> im having issues with getting inet.openurl() and inet.chunk() functions1- To test the inet.openurl() did you check if the "StrHeader = frmMain.inetDownload.GetHeader("Content-Length")" returned the correct content length ?2- To test the frmMain.inetDownload.GetChunk(CHUNK_SIZE, icByteArray), do the following only for the first call of GetChuck: check if the bytes received equal the bytes in the actual file, would be wise to create a simple sub here that displays the bytes of a byte array (you can do it anyway you want it), the file bytes could be viewed in some hex editor I think[EDIT] From MSDNRemarksThe OpenURL method's return value depends on the target of the URL. For example, if the target URL is the directory of an FTP server, the directory will be returned. On the other hand, if the target is a file, the file will be retrieved.The OpenURL method is equivalent to invoking the Execute method with a GET operation, followed by a GetChunk method invoked in the StateChanged event. The OpenURL method, however, results in a synchronous stream of data being returned from the site.If you are retrieving a binary file, be sure to use a byte array as a temporary variable before writing it to disk, as shown below: Link to comment Share on other sites More sharing options...
Lavos Posted September 24, 2016 Author Share Posted September 24, 2016 Agh, at this point im already pulling my hair, I give up. Thanks for the support though. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now