VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



WebBrowser Commands

by Matthew Gates (16 Submissions)
Category: Custom Controls/Forms/Menus
Compatability: Visual Basic 3.0
Difficulty: Beginner
Date Added: Wed 3rd February 2021
Rating: (2 Votes)

This is a list of some basic WebBrowser Commands and a few advanced ones.

Assumes
Shdocvw.dll and Comdlg32.dll required. I didn't bother to make this a Tutorial because I didn't think it belonged in that category. Most of the codes are commented on what it does.

Rate WebBrowser Commands

'Go to the previous webpage
WebBrowser1.GoBack
'Go to the present webpage
WebBrowser1.GoForward
'Go to the default IE home
WebBrowser1.GoHome
'Go to the default search page
WebBrowser1.GoSearch
'Refresh the current webpage
WebBrowser1.Refresh
'Navigate to a webpage
WebBrowser1.Navigate "www.YourSite.com"
  
'Printing:
WebBrowser1.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER
'Saving a webpage:
WebBrowser1.ExecWB OLECMDID_SAVEAS,OLECMDEXECOPT_PROMPTUSER
'Open a webpage file on located on your computer:
On Error GoTo fileOpenErr
CommonDialog1.CancelError = True
CommonDialog1.flags = &H4& Or &H100& Or cdlOFNPathMustExist Or cdlOFNFileMustExist
CommonDialog1.DialogTitle = "Select File To Open"
CommonDialog1.Filter = "HTM (*.htm)|*.htm|Txt Files (*.txt)|*.txt|Jpg Files (*.jpg)|*.jpg|Gif Files (*.gif)|*.gif|All Files (*.*)|*.*"
CommonDialog1.ShowOpen
webbrowser1.Navigate CommonDialog1.FileName
fileOpenErr:
Exit Sub
'Open a new web browser using your program and not IE:
Dim NewBrowser as Form1
NewBrowser.Show
NewBrowser.Caption = "MyBrowser"
'Load IE Preferences:
Dim dblReturn As Double
dblReturn = Shell("rundll32.exe shell32.dll,Control_RunDLL inetcpl.cpl,,0", 5)
'An advanced Stop:
If webbrowser1.Busy Then
webbrowser1.Stop
webbrowser1.GoBack
End If

Download this snippet    Add to My Saved Code

WebBrowser Commands Comments

No comments have been posted about WebBrowser Commands. Why not be the first to post a comment about WebBrowser Commands.

Post your comment

Subject:
Message:
0/1000 characters