| 416-621-9348 cgreaves@chrisgreaves.com | |
|---|---|
| Home Services Products |
Using List Boxes
In the previous lesson we learned how to initialize our list box with data; in this lesson we will learn how to detect and use the list box entry that has been selected by the user.
In VBE double-click on the list box. You will be rewarded with a skeletal event:
Private Sub lbProvinces_Click() End Sub
We will perform a very simple task, when the user clicks on an item in the list box – we will use the selected provincial code to prime the text box! This is not a very useful thing to do, but it will show you how to capture data that you can then use elsewhere in your application:
Private Sub lbProvinces_Click() Dim strProv As String strProv = Me.lbProvinces.List(Me.lbProvinces.ListIndex) Me.tbInput = strProv End Sub
Note that we have manipulated the string in two stages, first loading it into a string variable “strProv”, and then moving it to the text box. Remember that “Me” represents the current host – in this case the GUI form in which we find ourselves.
Loading
Toronto and Mississauga, Sunday, December 05, 2010 3:21 PM
Copyright © 1996-2010 Chris Greaves. All Rights Reserved.