'--------------------------------------------------- Form1 ---------------------------------------------------
Option Explicit
Private Declare Function InternetOpen Lib "wininet" 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" Alias "InternetOpenUrlA" (ByVal hInternetSession As Long, ByVal lpszUrl As String, ByVal lpszHeaders As String, ByVal dwHeadersLength As Long, ByVal dwFlags As Long, ByVal dwContext As Long) As Long
Private Declare Function InternetReadFile Lib "wininet" (ByVal hFile As Long, ByVal sBuffer As String, ByVal lNumBytesToRead As Long, lNumberOfBytesRead As Long) As Integer
Private Declare Function InternetCloseHandle Lib "wininet" (ByVal hInet As Long) As Integer
Dim Cancel_Download As Long
Function DownloadString(UrlFile As String) As String
Dim UrlInternetOpen As Long
Dim UrlInternetOpenUrl As Long
Dim UrlBuffer As String * 2048
Dim UrlBytes As Long
Dim UrlComplete As String
Cancel_Download = 0
UrlInternetOpen = InternetOpen("Download String", 1, vbNullString, vbNullString, 0)
UrlInternetOpenUrl = InternetOpenUrl(UrlInternetOpen, UrlFile, vbNullString, 0, &H80000000, 0)
Do
InternetReadFile UrlInternetOpenUrl, UrlBuffer, Len(UrlBuffer), UrlBytes
If UrlBytes = 0 Or Cancel_Download = 1 Then Exit Do 'Cancel_Download
UrlComplete = UrlComplete & Left$(UrlBuffer, UrlBytes)
DownloadBytes Len(UrlComplete) 'Function DownloadBytes
DoEvents
Loop
InternetCloseHandle UrlInternetOpenUrl
InternetCloseHandle UrlInternetOpen
DownloadString = UrlComplete
End Function
Function CancelDownload()
Cancel_Download = 1
End Function
Function DownloadBytes(Bytes As Long)
Me.Caption = "Download: " & Bytes & " Bytes"
End Function
Private Sub Command1_Click()
Call CancelDownload
End Sub
Private Sub Command2_Click()
RichTextBox1.Text = DownloadString("
http://ttv.tv2.dk/tekst.php?side=302")
End Sub
'--------------------------------------------------- Form1 ---------------------------------------------------