Results 1 to 3 of 3

Thread: Download from net

  1. #1

    Thread Starter
    Fanatic Member 007shahid's Avatar
    Join Date
    Feb 2001
    Posts
    562
    How do I download files from the net using VB

  2. #2
    Fanatic Member
    Join Date
    Jul 2000
    Location
    Manchester NH
    Posts
    833
    use the winsock control for or the Inet control
    Kurt Simons
    [I know I'm a hack but my clients don't!]

  3. #3
    Guest
    Or you could use the URLDownloadToFile API function.


    Code:
    Private 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
    
    Private 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
    
    
    Usage
    
    
    DownloadFile "http://www.site.com/file.txt", "c:\site.txt"
    
    'to return if download was successful:
    
    'Dim Dl As Boolean
    'Dl = DownloadFile ("http://www.site.com/file.txt", "c:\site.txt")
    'If Dl = True Then
    '    Msgbox "Download successful"
    'Else
    '    Msgbox "Download failed"
    'End If

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width