Results 1 to 8 of 8

Thread: Downloading Files/Text files From a internet address ...

  1. #1
    Guest

    Post

    How can i download files from the internet Like
    "www.Website.com/Progarm.exe"

  2. #2
    Lively Member
    Join Date
    Jan 1999
    Location
    India
    Posts
    85

    Post

    Is it that you want to download using a program or simply download a file?

    To download a file type the full path in IE address box. IE will download it for you.

    To do it to vb program you have to use Inet control.
    Go thro internet transfer control in vb.


  3. #3
    Member
    Join Date
    Aug 2013
    Posts
    47

    Re: Downloading Files/Text files From a internet address ...

    Hi All,

    Can I ask, how to read a textfile form the interntet. For example, www.sample.net/file.txt then display it on textbox...

  4. #4
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Re: Downloading Files/Text files From a internet address ...

    Quote Originally Posted by laudeniold View Post
    Hi All,

    Can I ask, how to read a textfile form the interntet. For example, www.sample.net/file.txt then display it on textbox...
    Here is how to read the contents on a text file and display it in a text box using the Inet Control.

    Code:
    Option Explicit
    'Add Microsoft Internet Transfer Control
    Private Sub cmdGet_Click()
    Dim strVariable As String
    strVariable = Inet.OpenURL("http://www.vbforums.com/attachment.php?attachmentid=74982&d=1260669911")
    Text1.Text = strVariable
    End Sub
    Also, instead of bumping a topic that is x number of years old and is not your own please create your own topic.
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  5. #5
    Hyperactive Member Rattled_Cage's Avatar
    Join Date
    Dec 2005
    Posts
    315

    Re: Downloading Files/Text files From a internet address ...

    i saw this posted a few weeks ago by someone asking the same and ive switched to it


    in formload or behind button
    Code:
    svrip.Text = URLSource("http://www.mysitesname/svrip.txt")
    and add a module .......with

    Code:
    Option Explicit
    Private Declare Function InternetOpen Lib "wininet.dll" Alias "InternetOpenA" (ByVal sAgent As String, ByVal lAccessType As Long, ByVal sProxyName As String, ByVal sProxyBypass As String, ByVal lFlags As Long) As Long
    Private Declare Function InternetOpenUrl Lib "wininet.dll" Alias "InternetOpenUrlA" (ByVal hInternetSession As Long, ByVal sURL As String, ByVal sHeaders As String, ByVal lHeadersLength As Long, ByVal lFlags As Long, ByVal lContext As Long) As Long
    Private Declare Function InternetReadFile Lib "wininet.dll" (ByVal hFile As Long, ByVal sBuffer As String, ByVal lNumBytesToRead As Long, lNumberOfBytesRead As Long) As Integer
    Private Declare Function InternetCloseHandle Lib "wininet.dll" (ByVal hInet As Long) As Integer
    Private Declare Function GetInputState Lib "user32" () As Long
    Private Const IF_NO_CACHE_WRITE = &H4000000   
    Private Const BUFFER_LEN = 256
    Public Function URLSource(ByRef URL As String) As String
        Dim strBuffer As String * BUFFER_LEN, lonRet As Long
        Dim strData As String, lonHandle As Long, lonSession As Long
        Dim lonResult As Long
        lonSession = InternetOpen("vb wininet", 1, vbNullString, vbNullString, 0)
        If lonSession Then lonHandle = InternetOpenUrl(lonSession, URL, vbNullString, 0, IF_NO_CACHE_WRITE, 0)
        If lonHandle Then
            lonResult = InternetReadFile(lonHandle, strBuffer, BUFFER_LEN, lonRet)
            strData = strBuffer
            Do While lonRet <> 0
                lonResult = InternetReadFile(lonHandle, strBuffer, BUFFER_LEN, lonRet)
                strData = strData & Mid$(strBuffer, 1, lonRet)
                If GetInputState Then DoEvents
            Loop
        End If
        lonResult = InternetCloseHandle(lonHandle)
        URLSource = strData
    End Function

  6. #6
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: Downloading Files/Text files From a internet address ...

    Seems kind of pointless when you can do it with one line with Inet


    Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.

  7. #7
    Hyperactive Member Rattled_Cage's Avatar
    Join Date
    Dec 2005
    Posts
    315

    Re: Downloading Files/Text files From a internet address ...

    ive had problems with inet

  8. #8
    PowerPoster dilettante's Avatar
    Join Date
    Feb 2006
    Posts
    24,487

    Re: Downloading Files/Text files From a internet address ...

    You can also use the AsyncRead method for a simple GET like this. No msinet.ocx required and no raft of API calls with busy-wait loops and crash inducing, data corrupting DoEvents calls.

    Or there are at least three HTTP Request objects built into Windows you can use.
    Last edited by dilettante; Nov 12th, 2013 at 02:30 AM.

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