After much searching the Internet and found www.vbforums.com did not answer my question. The search engine of www.vbforums.com I signed "download file from Google Drive" after seven pages I stopped reading.
This code works great and I use it if I want to download the file from the website
But if you want to download from the Google Drive you can not with him.Code:Option Explicit Private Sub cmdDownload_Click() Screen.MousePointer = vbHourglass ProgressBar1.Value = 0 ProgressBar1.Visible = True 'show progressbar 'This downloads the file and saves to your machine DownloadFile "http://www.somesite.com/somefile.exe", App.Path & "\somefile.exe" Screen.MousePointer = vbDefault MsgBox "Download Complete" ProgressBar1.Visible = False End Sub Private Sub Form_Load() Me.Caption = "Sample Downloader With Progress Bar" ProgressBar1.Visible = False End Sub Sub DownloadProgress(intPercent As String) ProgressBar1.Value = intPercent ' Update file download progress End Sub 'Public Function DownloadFile(strURL As String, strDestination As String) As Boolean Public Sub DownloadFile(strURL As String, strDestination As String) 'As Boolean Const CHUNK_SIZE As Long = 1024 Dim intFile As Integer Dim lngBytesReceived As Long Dim lngFileLength As Long Dim strHeader As String Dim b() As Byte Dim i As Integer DoEvents With Inet1 .URL = strURL .Execute , "GET", , "Range: bytes=" & CStr(lngBytesReceived) & "-" & vbCrLf While .StillExecuting DoEvents Wend strHeader = .GetHeader End With strHeader = Inet1.GetHeader("Content-Length") lngFileLength = Val(strHeader) DoEvents lngBytesReceived = 0 intFile = FreeFile() Open strDestination For Binary Access Write As #intFile Do b = Inet1.GetChunk(CHUNK_SIZE, icByteArray) Put #intFile, , b lngBytesReceived = lngBytesReceived + UBound(b, 1) + 1 DownloadProgress (Round((lngBytesReceived / lngFileLength) * 100)) DoEvents Loop While UBound(b, 1) > 0 Close #intFile End Sub
link for share its:
https://drive.google.com/file/d/0B9i...ew?usp=sharing
If someone has time to be a very simple example, I am a beginner in VB6, I was grateful to him for help. Thank you for me and others who know so little like me
![]()





Reply With Quote
