Article ID: 182033
Article Last Modified on 8/30/2004
Private Sub Form_Load()
WebBrowser1.Navigate "c:\mytest.htm"
End Sub
Private Sub WebBrowser1_BeforeNavigate2(ByVal pDisp As Object, _
URL As Variant, Flags As Variant, _
TargetFrameName As Variant, PostData As Variant, _
Headers As Variant, Cancel As Boolean)
Dim Ev As String
If UCase$(Left$(URL, 6)) = "EVENT:" Then
'this is our event, process it and cancel navigation
Ev = UCase$(Mid$(URL, 7))
Select Case Ev
Case "HELLO"
MsgBox "Hello from VB App"
'set a field on HTML page
WebBrowser1.Document.All("field1").Value = _
"Hello from VB"
Case "CLOSE"
If MsgBox("Are you sure you want to exit?", _
vbYesNo) = vbYes Then
End
End If
End Select
Cancel = True
End If
End Sub
<HTML><BODY>
<INPUT type=text name=field1><p>
<INPUT type=button name=Hello value="Hello World">
<INPUT type=button name=Close value="Close App">
<SCRIPT LANGUAGE="VBScript">
Sub Close_OnClick()
location.href = "Event:Close"
End Sub
Sub Hello_OnClick()
location.href = "Event:Hello"
End Sub
</SCRIPT>
</BODY></HTML>
Keywords: kbhowto kb32bitonly KB182033