Results 1 to 4 of 4

Thread: Requires VB code for repeating process

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2011
    Posts
    3

    Requires VB code for repeating process

    Hello Friends
    Please help me I am new in developer field & try developing little software I have ( search from net)following code & want to continuous download file after 30 second without Download OK or Error in Download
    vb Code:
    1. Private Declare Function URLDownloadToFile Lib "urlmon" Alias _
    2.     "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, _
    3.     ByVal szFileName As String, ByVal dwReserved As Long, _
    4.     ByVal lpfnCB As Long) As Long
    5.  
    6. Private Sub Command1_Click()
    7. ' Note that this file is 2M, so you might want to try with something simpler
    8. Dim errcode As Long
    9. Dim url As String
    10. Dim localFileName As String
    11.  
    12. url = "http://mysite.com/data.csv"
    13. localFileName = "c:\data.csv"
    14.  
    15. errcode = URLDownloadToFile(0, url, localFileName, 0, 0)
    16. If errcode = 0 Then
    17.     MsgBox "Download ok"
    18. Else
    19.     MsgBox "Error while downloading"
    20. End If
    21. End Sub
    Thanks In Advance
    Last edited by Hack; Jul 25th, 2011 at 11:07 AM. Reason: Added Highlight Tags

  2. #2
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: Requires VB code for repeating process

    I don't fully understand your question. What do you mean by "continuous download file after 30 second"? Do you want to wait 30 seconds? Stop after 30 seconds? And what does "without Download OK or Error in Download" mean? Do you mean you never want to see those messages?

  3. #3
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Requires VB code for repeating process

    errcode = URLDownloadToFile(0, url, localFileName, 0, 0)

    That above line is returning success or failure. If errCode=0 then success.
    If you don't want to see the message boxes then remove those lines of code in the snippet you posted. However, you should handle failed downloads: errCode<>0

    Here's the official documentation for that API
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  4. #4

    Thread Starter
    New Member
    Join Date
    Jul 2011
    Posts
    3

    Re: Requires VB code for repeating process

    Quote Originally Posted by MartinLiss View Post
    I don't fully understand your question. What do you mean by "continuous download file after 30 second"? Do you want to wait 30 seconds? Stop after 30 seconds? And what does "without Download OK or Error in Download" mean? Do you mean you never want to see those messages?
    See Friend
    I just want to download a file from web link in continuos time frame. Supose I click start button file get download after that I don't need to click start button process may start atuomatically after 30 second. Get ?
    Actually I want to download yahoo delayed stock quote in file on local drive.
    Pls 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