Table of Contents
Examples
Execute SQL (ADO)
http://www.classanytime.com/mis333k/sjdaoadorecordsets.html#tof
Dim MySQL as String MySQL = “UPDATE tblPeople SET IsSelected = Yes;” CurrentProject.Connection.Execute MySQL
' Some examples of SQL statements (also see DAO above)
CurrentProject.Connection.Execute “UPDATE tblPeople SET IsSelected = Yes;” CurrentProject.Connection.Execute “UPDATE tblPeople SET Salary = Salary*1.02 WHERE Sex='M';”
' Alternative ADO syntax
Dim cd As New ADODB.Command Dim cn As ADODB.Connection Set cn = CurrentProject.Connection cd.ActiveConnection = cn cd.CommandText = MySQL cd.Execute
Internet Explorer Objects - msdn.microsoft.com
* http://msdn.microsoft.com/en-us/library/ms970672.aspx
* http://msdn.microsoft.com/en-us/library/ms970456.aspx
* http://www.codeproject.com/KB/vb/kirangoka.aspx
* http://msdn.microsoft.com/en-us/library/aa752084(VS.85).aspx
Once you have an instance of the Internet Explorer, you can manipulate it through properties and methods. For example, if you want the browser to appear and navigate to the New Technology Solutions, Inc., web site, you could use the following code:
MyBrowser.Visible = True MyBrowser.Navigate “http://www.vb-bootcamp.com”
You can use this type of coding to add browsing capabilities to Visual Basic projects or to create utilities for the browser. Listing 3-2 shows a complete project in Visual Basic that implements a Favorites list for the Internet Explorer browser. The project uses a small Microsoft Access database to keep track of your favorite URLs. These URLs are placed in a list box, from which users can pick a specified URL and cause the browser to navigate to it. Figure 3-6, on page 51, shows an example of the Favorites list box.
`This demo implements a Favorites list for the Internet `Explorer 3.0. The list of favorite URLs is stored `in a Microsoft Access database. `This demo automatically launches the Internet Explorer. `The user can jump to a favorite URL by selecting it from `the list and clicking on the Navigate button or just `double-clicking on the URL. Option Explicit Public MyBrowser As SHDocVw.InternetExplorer
Private Sub Form_Load()
`Get an instance of Internet Explorer 3.0 Set MyBrowser = New SHDocVw.InternetExplorer MyBrowser.Visible = True `Fill list box with favorites Call FillList
End Sub
Private Sub cmdNavigate_Click()
If lstFavorites.ListIndex = -1 Then Exit Sub `Use the Navigate method to display the `selected URL MyBrowser.Navigate lstFavorites.List(lstFavorites.ListIndex)
End Sub
Private Sub lstFavorites_DblClick()
cmdNavigate.Value = True
End Sub
Private Sub FillList()
`Author: New Technology Solutions, Inc. `Purpose: Fill list box from Favorites database `6/2/96 Original
Dim dbFavorites As DAO.Database Dim rsFavorites As DAO.Recordset `Get favorites from database Set dbFavorites = DBEngine.Workspaces(0) _
.OpenDatabase(App.Path & "\favorite.mdb") Set rsFavorites = dbFavorites.OpenRecordset _ ("SELECT * FROM Favorites", dbOpenSnapshot) If rsFavorites.BOF And rsFavorites.EOF Then Exit Sub lstFavorites.Clear rsFavorites.MoveFirst `Fill list box Do While Not rsFavorites.EOF lstFavorites.AddItem rsFavorites!URL rsFavorites.MoveNext Loop rsFavorites.Close dbFavorites.Close Set rsFavorites = Nothing Set dbFavorites = Nothing
End Sub
Private Sub cmdExit_Click()
Unload Me
End Sub