Monday, May 28, 2012

Fungsi Untuk Mendownload URL

Di bawah ini merupakan fungsi untuk mendownload sebuah URL.
Option Explicit 

Private Function
DownloadFile(ByVal sFileSource As String, ByVal sDestFile As String) As Boolean
Dim
bytes() As Byte
Dim
fnum As Integer
bytes() = Inet1.OpenUrl(sFileSource, icByteArray)
fnum = FreeFile

Open
sDestFile For Binary Access Write As #fnum
Put #fnum, , bytes()
Close #fnum

DownloadFile = True
End Function

Contoh penggunaan fungsi di atas:
Private Sub Command1_Click() 
Call DownloadFile("http://4basic-vb.blogspot.com", "C:\download.html")
End Sub