Visual Basic 2008 Programming: Business Applications with a Design Perspective
Chapter 1 Chapter 2 Chapter 3 Chapter 4 Chapter 5 Chapter 6 Chapter 7 Chapter 8 Chapter 9
Chapter 10 Chapter 11 Chapter 12 Chapter 13 Chapter 14 Appendix A Appendix B Appendix C Home
Loading
Last change: February 13 2016 18:48:19.

 Chapter in PDF

Table of Contents

Chapter 3: User Interface Design: Visual Basic Controls and Events
Last change: February 13 2016 18:47:26.
<<PreviousNext>>

The Click Event: Buttons and List Boxes

Most controls recognize the Click event. However, this event is most often used in conjunction with the button, whose text typically indicates to the user what to expect. For example, you may have a program for the user to enter certain data required to perform certain computation. When the user is ready for your program to compute, he or she will click a button with a text Compute. In this case, it is certainly clear to you that you will place your code to perform the computation in the button’s Click event. As another example, in most forms, a button is used for the user to end the program. Typically, the button is named btnQuit and its Text property is set to Quit. Remember how the code was presented previously? Here it is again:

Private Sub btnQuit_Click(ByVal Sender As System.Object, ByVal e As System.EventArgs) Handles btnQuit.Click Me.Close() End Sub

When the list box’s SelectionMode property is set to one, a click on a list item will cause the item to be selected. In this case, the Click event is a good choice to handle the user’s selection.
Note that because the Click event is triggered for most controls when the user clicks on them, there is a tendency to place code in this event for these controls. However, in most cases, many situations may turn out as a result of a single click, requiring additional care and code to handle these ramifications. In some cases, it is easier to use other events specifically designed for these situations. The following sub-subsections discuss these events.

Last change: February 13 2016 18:47:26.
<<PreviousNext>>