Date: Mon, 10 Feb 2003 16:16:20 -0600 (CST) From: Mark Jacobson To: 810-151-01@uni.edu Subject: Back and Forward buttons on browser application... Hi Visual Basic students, One student asked me last week and another asked me today about how to get their browser application to have an effective BACK button, so I am including the VB code here to illustrate how that could be done. I tried it for both the BACK and the FORWARD buttons and tested it out, and it works fine. I will make a link on the class web page to where you can read about the documentation (very confusing) for how to do this. Here is my code: ' Written on February 10th, 2003 for 810:151 class ' Illustrates how to implement the browser's BACK and FORWARD buttons by ' using the WebBrowser control's CommandStateChange event Private Sub cmdGoToUSD_Click() WebBrowser1.Navigate "http://www.usd.edu" End Sub Private Sub cmdGoToUNI_Click() WebBrowser1.Navigate "http://www.uni.edu" End Sub Private Sub cmdGoToUSC_Click() WebBrowser1.Navigate "http://www.usc.edu" End Sub Private Sub WebBrowser1_CommandStateChange(ByVal Command As Long, _ ByVal Enable As Boolean) ' Print "Command = " & Command & " Enable = " & Enable If Command = CSC_NAVIGATEBACK Then ' Command = 2 would work here too cmdGoBack.Enabled = Enable ElseIf Command = CSC_NAVIGATEFORWARD Then ' Command = 1 would work too. cmdGoForward.Enabled = Enable End If End Sub Private Sub cmdGoForward_Click() WebBrowser1.GoForward End Sub Private Sub cmdGoBack_Click() WebBrowser1.GoBack End Sub See you on Wednesday. Friday is the end of this class on Visual Basic, and its amazing how fast 1/3 of a semester flies by! Mark