'------------------------------------------- Form1 -------------------------------------------
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 DownloadBytes(Bytes As Long)
Me.Caption = "Download: " & Bytes & " Bytes"
End Function
Private Sub Command1_Click()
RichTextBox1.Text = DownloadString("
http://www.eksperten.dk/spm/164352")
End Sub
Private Sub Command2_Click()
Cancel_Download = 1
End Sub
Private Sub Form_Load()
Command1.Caption = "Download"
Command2.Caption = "Cancel"
RichTextBox1.Text = ""
End Sub
'------------------------------------------- Form1 -------------------------------------------
hvis du vil loade en file fra din harddisk:
RichTextBox1.LoadFile "c:\index.htm"