How can i download files from the internet Like
"www.Website.com/Progarm.exe"
Printable View
How can i download files from the internet Like
"www.Website.com/Progarm.exe"
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.
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.
Also, instead of bumping a topic that is x number of years old and is not your own please create your own topic.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
i saw this posted a few weeks ago by someone asking the same and ive switched to it
in formload or behind button
and add a module .......withCode:svrip.Text = URLSource("http://www.mysitesname/svrip.txt")
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
Seems kind of pointless when you can do it with one line with Inet
ive had problems with inet
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.