Evo imas kod ispod.
Stavi na VB formu MultiLine text box Text1 i kopiraj kod u kod sekciju (stavi i scroll barove za Text1).
Kod radi u Activate eventu forme (kad forma postaje vidljiva).
Code:
Const INTERNET_OPEN_TYPE_PRECONFIG = 0
Const INTERNET_FLAG_RELOAD = &H80000000
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 pub_lngInternetSession 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 Sub InternetSetStatusCallback Lib "wininet.dll" (ByVal pub_lngInternetSession As Long, ByVal lpfnInternetCallback As Long)
Private Declare Function InternetConnect Lib "wininet.dll" Alias "InternetConnectA" (ByVal pub_lngInternetSession As Long, ByVal sServerName As String, ByVal nServerPort As Integer, ByVal sUsername As String, ByVal sPassword As String, ByVal lService As Long, ByVal lFlags As Long, ByVal lContext As Long) As Long
Private Declare Function HttpOpenRequest Lib "wininet.dll" Alias "HttpOpenRequestA" (ByVal hHttpSession As Long, ByVal sVerb As String, ByVal sObjectName As String, ByVal sVersion As String, ByVal sReferer As String, ByVal something As Long, ByVal lFlags As Long, ByVal lContext As Long) As Long
Private Declare Function HttpSendRequest Lib "wininet.dll" Alias "HttpSendRequestA" (ByVal hHttpRequest As Long, ByVal sHeaders As String, ByVal lHeadersLength As Long, sOptional As Any, ByVal lOptionalLength As Long) As Integer
Private Declare Function HttpQueryInfo Lib "wininet.dll" Alias "HttpQueryInfoA" (ByVal hHttpRequest As Long, ByVal lInfoLevel As Long, ByRef sBuffer As Any, ByRef lBufferLength As Long, ByRef lIndex As Long) As Integer
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 InternetWriteFile Lib "wininet.dll" (ByVal hFile As Long, ByVal sBuffer As String, ByVal lNumBytesToWrite As Long, dwNumberOfBytesWritten As Long) As Integer
Private Declare Function InternetCloseHandle Lib "wininet.dll" (ByVal hInet As Long) As Integer
Private Sub Form_Activate()
On Error GoTo Err
Dim hInternetSession As Long
Dim hUrlFile As Long
Dim sReadBuffer As String * 4096 ' 4k
Dim sBuffer As String
Dim lNumberOfBytesRead As Long
Dim bDoLoop As Boolean
hInternetSession = InternetOpen("GetPage", INTERNET_OPEN_TYPE_PRECONFIG, vbNullString, vbNullString, 0)
If hInternetSession = 0 Then GoTo Err
hUrlFile = InternetOpenUrl(hInternetSession, "http://eurora3d.com/eurora3d.html", vbNullString, 0, INTERNET_FLAG_RELOAD, 0)
If hUrlFile = 0 Then GoTo Err
bDoLoop = True
While bDoLoop
sReadBuffer = ""
bDoLoop = InternetReadFile(hUrlFile, sReadBuffer, _
Len(sReadBuffer), lNumberOfBytesRead)
sBuffer = sBuffer & Left$(sReadBuffer, lNumberOfBytesRead)
If Not CBool(lNumberOfBytesRead) Then bDoLoop = False
Wend
InternetCloseHandle (hUrlFile)
InternetCloseHandle (hInternetSession)
Dim st As Long, en As Long
Text1.Text = sBuffer ' Ovde
st = InStr(1, sBuffer, "<TITLE>", vbTextCompare)
If st = 0 Then GoTo Err
st = st + 7
en = InStr(st, sBuffer, "</TITLE>", vbTextCompare)
If en = 0 Then GoTo Err
Me.Caption = Mid(sBuffer, st, en - st) 'Ovde
Exit Sub
Err:
Debug.Print Err.Description
End Sub