URLDownloadToFile question
Hey All,
I found this code on one of the threads...
Code:
Public Declare Function URLDownloadToFile Lib "urlmon" Alias _
"URLDownloadToFileA" (ByVal pCaller As Long, _
ByVal szURL As String, _
ByVal szFileName As String, _
ByVal dwReserved As Long, _
ByVal lpfnCB As Long) As Long
Public Function DownloadFile(URL As String, _
LocalFilename As String) As Boolean
Dim lngRetVal As Long
lngRetVal = URLDownloadToFile(0, URL, LocalFilename, 0, 0)
If lngRetVal = 0 Then DownloadFile = True
End Function
I was wondering if anyone could find any problem with changing
the last "IF" statement to something like the following...
Code:
If lngRetVal = 0 Then
DownloadFile = True
MsgBox "Download Complete!"
Else
DownloadFile = False
MsgBox "You are NOT Connected to the Internet!"
End If
Thanks in advance,
Ron
Re: URLDownloadToFile question
Quote:
Originally posted by rdcody
Hey All,
I found this code on one of the threads...
Code:
Public Declare Function URLDownloadToFile Lib "urlmon" Alias _
"URLDownloadToFileA" (ByVal pCaller As Long, _
ByVal szURL As String, _
ByVal szFileName As String, _
ByVal dwReserved As Long, _
ByVal lpfnCB As Long) As Long
Public Function DownloadFile(URL As String, _
LocalFilename As String) As Boolean
Dim lngRetVal As Long
lngRetVal = URLDownloadToFile(0, URL, LocalFilename, 0, 0)
If lngRetVal = 0 Then DownloadFile = True
End Function
I was wondering if anyone could find any problem with changing
the last "IF" statement to something like the following...
Code:
If lngRetVal = 0 Then
DownloadFile = True
MsgBox "Download Complete!"
Else
DownloadFile = False
MsgBox "You are NOT Connected to the Internet!"
End If
Thanks in advance,
Ron
The code is perfectly fine the way it is
VB Code:
If DownloadFile("http://www.vbforums.com/", "c:\a.txt") then
Msgbox "Download Complete"
else
Mesgbox "There was some kind of error"
End If