Share via


Visual Basic Concepts

Retrieving Data from an HTML Page

You can retrieve data from elements on an HTML page using Dynamic HTML. This allows you to retrieve and manipulate data without making trips to the server for processing. Using properties of the objects on the page, you can gather data, perform calculations on it in your Visual Basic code, and display responses without ever transferring processing from the client to the server, which can increase your response time to user actions and requests.

For example, suppose you are working with an application that allows users to query books from a database by entering the author's name, the title of the book, or the call number of the book in text fields on a search page. The text fields are named Author, Title, and CallNo. When a query is submitted from the application's search page, the application must retrieve the value from these text fields.

The following code shows how you could use variables to retrieve the values from these fields:

Private function cmdSearch_onclick() As Boolean
   'Create variables to contain the search criteria.
   Dim sAuthor as String
   Dim sTitle as String
   Dim sCallNo as String

   'Retrieve criteria from the page.
   sAuthor=Me.author.Value
   sTitle=Me.title.Value
   sCallNo=Me.callno.Value

   'Code here to process the data and return the query.
End Function

This code uses the Value property of the HTML text fields to retrieve the fields' data. Your code would open a database connection, create a recordset, and return the appropriate records. This data could then be sent to the user.