Wednesday, August 15, 2007

WebBrowser Navigate Method

How To Use WebBrowser HEADERS Param in Navigate Method Step-by-Step Example




1.Create a new Standard .exe project in Microsoft Visual Basic 5.0. Form1 is created by default.
2.From the Project menu, click Components.
3.Select the Microsoft Internet Controls component. Click OK.
4.Add the following controls to Form1:
   Control           Name
-------------- ---------
Command Button Command1
WebBrowser WebBrowser1
5.In Form1's code window, add the following code:
Option Explicit

Private Sub Command1_Click()

WebBrowser1.Navigate URL:= "http://www.microsoft.com" _
,Headers:= "Authorization: Basic XXXXXX" & chr$(13) & chr$(10)
' Note: All headers must be terminated with a
' carriage return linefeed pair.

If WebBrowser1.Visible = False Then
WebBrowser1.Visible = True
End If
End Sub
6.From the File menu, click Save Project1.
7.From the Run menu, click Start. Note that when you click Command1, the WebBrowser appears and automatically loads the URL specified in the URL parameter of Navigate.

No comments: