Results 1 to 9 of 9

Thread: Download Program [RESOLVED]

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2005
    Location
    Scotland
    Posts
    123

    Resolved Download Program [RESOLVED]

    HELLO AGAIN

    I have a form two text boxes and a command button

    The user enters the url for a download into one text box and then the dir they want it to go to on their own machine

    When they press the command button the program should download but it i dont know the code for this problem.

    Hopefully one of you can help me
    Last edited by Aaron Smith; Apr 30th, 2005 at 05:16 AM.
    Regards
    Aaron Smith

    Did my post help you, rate my post

    When Quoting VB Code use [vbcode][/vbcode]

    When your problem has been resolved change to *subject* [RESOLVED]

  2. #2
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Download Program

    You could try the URLDownloadToFile API function. I've made a simple wrapper sub around it. Simply call DownloadFile with the URL and the name and path of the local file.
    VB Code:
    1. Private Declare Sub URLDownloadToFile _
    2.  Lib "URLMON.dll" ( _
    3.  ByVal lpCaller As Long, _
    4.  ByVal szUrl As String, _
    5.  ByVal szFilename As String, _
    6.  ByVal dwReserved As Long, _
    7.  ByVal lpBindStatusCallback As Long)
    8.  
    9. Public Sub DownloadFile(ByVal sUrl As String, ByVal sLocalFile As String)
    10.     URLDownloadToFile 0, sUrl, sLocalFile, 0, 0
    11. End Sub

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Mar 2005
    Location
    Scotland
    Posts
    123

    Re: Download Program

    Jocain thanks for replying but

    Quote Originally Posted by Joacim Andersson
    You could try the URLDownloadToFile API function. I've made a simple wrapper sub around it. Simply call DownloadFile with the URL and the name and path of the local file.
    I have no idea wot that means or wot i have to do with my form and the code
    Regards
    Aaron Smith

    Did my post help you, rate my post

    When Quoting VB Code use [vbcode][/vbcode]

    When your problem has been resolved change to *subject* [RESOLVED]

  4. #4
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Download Program

    Copy and paste the above code to the form. In the Click event of your button you call the DownloadFile sub:
    VB Code:
    1. Private Sub Command1_Click()
    2.     Call DownloadFile([i]UrlToFile[/i], [i]LocalFileName[/i])
    3. End Sub

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Mar 2005
    Location
    Scotland
    Posts
    123

    Re: Download Program

    thanks jocain i have made the program now

    Regards

    Aaron
    Regards
    Aaron Smith

    Did my post help you, rate my post

    When Quoting VB Code use [vbcode][/vbcode]

    When your problem has been resolved change to *subject* [RESOLVED]

  6. #6
    PowerPoster Keithuk's Avatar
    Join Date
    Jan 2004
    Location
    Staffordshire, England
    Posts
    2,238

    Re: Download Program [RESOLVED]

    Joacim.

    I can't get this code to work. I get an error Can't find DLL entry point URLDownloadToFile in URLMON.DLL

    VB Code:
    1. Private Sub Command1_Click()
    2.  
    3. Call DownloadFile("http://www.martin2k.co.uk/forums/index.php?act=Attach&type=post&id=511", "c:\temp\regclean.zip")
    4.  
    5. End Sub
    Am I coding it right?
    Keith

    I've been programming with VB for 25 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.

  7. #7

    Re: Download Program [RESOLVED]

    I get the same error =D

    EDIT: Here's an inet example that works: http://www.vbforums.com/showthread.p...load+file+inet
    Last edited by Menekali; Apr 30th, 2005 at 04:09 PM.

  8. #8
    PowerPoster Keithuk's Avatar
    Join Date
    Jan 2004
    Location
    Staffordshire, England
    Posts
    2,238

    Re: Download Program [RESOLVED]

    Yes I've tried that progress.zip and it works. I just wondered why Joacim posted that code if it doesn't work, as he tried it. I wonder what Aaron is using now its resolved.
    Keith

    I've been programming with VB for 25 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.

  9. #9
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Download Program [RESOLVED]

    Sorry chaps Please let me know what you haven't got working. I'm more then willing to help you out if you need any help!

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