Directory listing of http: uap.unnes.ac.id ebook biblebook Visual Basic 6 com & Library Books

8

C H A P T E R

M ore About
Bound Controls









In This Cha pter

I

n the previo us c hapter, I sho wed yo u ho w to build a pro gram witho ut any c o de using o nly bo und c o ntro ls and the
ADO Data Control. In this c hapter, I will c o ntinue disc ussing

bo und c o ntro ls by talking abo ut so me o ther pro perties and
events that yo u c an use to help ensure that o nly valid data is
sto red in yo ur database. Then I’m go ing to disc uss a few o ther
useful c o ntro ls that have spec ial features to help ensure that
yo ur data is c o rrec t befo re it gets into the database.

Bound Controls Revisited
Bo und c o ntro ls are no t as simple as I led yo u to believe in
Chapter 7. There are several o ther pro perties, metho ds, and
events that allo w yo u to fine-tune ho w the user interac ts with
the c o ntro l.

Key properties
All bo und c o ntro ls c o ntain the pro perties listed in Table 8-1,
whic h affec t the way the c o ntro l wo rks with the user and with
the database.

Key methods
While the SetFocus metho d isn’t direc tly used in binding a
c o ntro l to a data so urc e, it is so metimes used in perfo rming

data validatio n.

Bo und co ntro ls
revisited
Using the Masked
Edit co ntro l
Using the

DateTimePicker
co ntro l
Using the DataCombo
co ntro l










120

Part II ✦ Beginning Database Programming

Table 8-1
Key Properties of Bound Controls
Property

Description

CausesValidation

A Boolean value, w here TRUE m eans that the Validation
event for the control previously focused w ill be fired
before the focus is shifted to this control.

DataChanged

A Boolean value, w here TRUE m eans that either the user

has changed the value of the control or the program has
changed the value of the control.

DataField

A String value containing the field nam e to w hich the
control is bound.

DataFormat

An object reference to an StdDataFormat object w hich
contains inform ation about how to form at the value
displayed by the control.

DataMember

A String value that identifies w hich set of data should be
used w hen a DataSource has m ore than one set of data.

DataSource


An object reference to an object that can act as a data
source. Com m on data sources include the ADO Data
Control, a Recordset object or a Class m odule w here
the DataSourceBehavior property is set to
vbDataSource (1).

Object .SetFocus ( )
The SetFocus metho d is used to transfer the fo c us to the c o ntro l spec ified by
o bje ct. If the c o ntro l spec ified by o bje ct isn’t visible o r c an’t ac c ept the fo c us, a
runtime erro r will o c c ur.

Key events
Mo st c o ntro ls that c an be bo und have a set o f events that will be fired as the user
interac ts with the c o ntro l. These events c an be used to verify that the info rmatio n a
user enters into the c o ntro l is c o rrec t.

Event Change ( )
The Change event is fired eac h time the value o f a c o ntro l c hanges. This c an happen
if the user updates the value in the c o ntro l o r explic itly sets the Value, Caption, o r

Text pro perty in c o de.

Chapter 8 ✦ M ore About Bound Controls

Event GotFocus ( )
The GotFocus event fired befo re a c o ntro l rec eives the fo c us.

Event KeyDown (KeyCode As Integer, Shift As Integer)
The KeyDown event is fired whenever the user presses a key while the c o ntro l has
the fo c us, where KeyCode is an Integer value c o ntaining the key c o de o f the key
that was pressed. This value is no t the ASCII c harac ter value asso c iated with the key.

Shift is an Integer value that indic ates the status o f the Shift, Alt, and Ctrl keys.

Event KeyPress (KeyAscii As Integer)
The KeyPress event is fired whenever a key is pressed and released, where KeyAscii
c o ntains the ASCII c o de o f the key that was pressed. Changing this value to zero in the
event c anc els the keystro ke.

Event KeyUp (KeyCode As Integer, Shift As Integer)

The KeyUp event is fired whenever the user releases a key while the c o ntro l has the
fo c us, where KeyCode is an Integer value c o ntaining the key c o de o f the key that
was released. This value is no t the ASCII c harac ter value asso c iated with the key.

Shift is an Integer value that indic ates the status o f the Shift, Alt, and Ctrl keys.

Event LostFocus ( )
The LostFocus event is fired just befo re the fo c us is transferred to ano ther c o ntro l.

Event Validate (Cancel As Boolean)
The Validate event is used to verify that the c o ntents o f a c o ntro l are valid befo re
the fo c us is shifted to ano ther c o ntro l. The Validate event will o nly be triggered if
the destinatio n c o ntro l has the CausesValidation pro perty set to TRUE. This is
the c ase where Cancel is a Boolean value, and TRUE means that the fo c us sho uld
no t be shifted to the next c o ntro l. By default, Cancel is set to FALSE.

Data validation
There are basic ally fo ur ways to verify that the user has entered the c o rrec t data
into a c o ntro l like a TextBox:


✦ Change event
✦ KeyPress, KeyUp, and KeyDown events
✦ GotFocus and LostFocus events
✦ Validate event

121

122

Part II ✦ Beginning Database Programming

Eac h appro ac h is disc ussed b elo w, alo ng with any o f its advantages and disadvantages.

Using the Change event
The Change event is triggered eac h time the value o f the c o ntro l is c hanged. While
at first this may be the ideal event with whic h to verify c hanges, it turns o ut it is the
least prac tic al appro ac h.
Co nsider a TextBox c o ntro l. Eac h time the user types a c harac ter into the text windo w, the c hange event is fired. Also , anytime yo u c hange the Text pro perty in yo ur
pro gram, yo u trigger the Change event. This c an make things really c o mplic ated if
yo u c ho o se to c hange the value o f the c o ntro l while in the Change event.


Using the KeyPress, KeyUp, and KeyDown events
The KeyPress, KeyUp, and KeyDown events are fired whenever a user presses a key
o n the keybo ard. Like the Change event, these events are so mewhat limited in their
usefulness fo r validating data. Ho wever, yo u c an trap the keystro kes as they are
entered and translate them into so mething o r perfo rm a spec ial task.
Fo r instanc e, yo u c an inc lude so me c o de in the KeyPress event to translate any
lo werc ase c harac ters into their upperc ase equivalents auto matic ally. Yo u c an also
define c ertain keystro kes, suc h as the Esc key, to perfo rm spec ial func tio ns, like
resto ring the o riginal value fo r the field fro m the database (see Listing 8-1).

Listing 8-1: The Text1_KeyPress event in Customer
Information Editor
Private Sub Text1_KeyPress(KeyAscii As Integer)
If Chr(KeyAscii) >= “a” And Chr(KeyAscii)

Convert the follow ing characters to uppercase.

<


Convert the follow ing characters to low ercase.

A

A required alphanum eric character.

A

An optional alphanum eric character.

9

An optional num eric character.

C

Sam e as & (ensures com patibility w ith Microsoft Access).

?


A required alphanum eric character.

Other

Any other character is treated as a literal.

Creating an input mask
When pro gramming the Masked Edit c o ntro l, the first step is to build an input
mask. The best way to start is to c ho o se the mask c harac ters that reflec t ho w yo ur
users enter their data and insert them into the Mask pro perty. Yo u c an add literal
c harac ters suc h as parentheses and dashes to make the input mask easier to use.
Table 8-5 lists so me sample values fo r the Mask pro perty.

129

130

Part II ✦ Beginning Database Programming

Table 8-5
Sample M asks

Caution

Input M ask

Description

(# # # ) # # # -# # # #

A telephone num ber.

# # # # -# # # # -# # # # -# # # #

A credit card num ber.

# # # -# # -# # # #

A social security num ber.

> A< AAAAAAAA

A nam e field w ith the first character alw ays in uppercase
and the follow ing characters alw ays in low ercase.

> AAAAAAAAAA

A nam e field w ith all characters converted to uppercase.

?# :# #

A tim e value.

##/ ##/ ##

A date value.

The mask didn’t work: Just because you use an input m ask to ensure the input is
in the proper form at doesn’t m ean that the value entered w ill alw ays be correct.
For instance, som eone could enter (000) 000-0000 as a telephone num ber or
they could enter 99/ 99/ 99 as a date. Both of these values are invalid, yet they
m eet the requirem ents specified by the input m ask. In these cases, you can use
the Validate event or another control, such as the DateTimePicker, to
ensure that the user’s data is correct.

As the user enters c harac ters into the c o ntro l at runtime, eac h c harac ter is validated
against the input mask. Any literal c harac ters are fro zen o n the sc reen and are auto matic ally skipped o ver. If the user enters a c harac ter that isn’t c o mpatible with the
input mask, it is igno red, unless yo u have c o ded the ValidateError event. Then
the event will be fired and yo u c an respo nd in whatever fashio n yo u wish.
Tip

A real multimedia solution: I like to use the full m ultim edia capabilities of a
PC/ XT to let the user know that they typed an invalid character in the Masked
Edit control. Therefore, in the ValidateError event, I’ll include a Beep statem ent to generate an audible signal to the user.

Prompting the user
A pro mpt c harac ter c an be defined using the PromptChar pro perty. This c harac ter
will be displayed in the eac h po sitio n o f the field where the user is expec ted to enter
a value. Generally, yo u will want to use the undersc o re ( _ ) c harac ter as the pro mpt
c harac ter, but yo u may want to supply a value like a zero o r a spac e depending o n
the input mask. Fo r instanc e, if yo u set PromptChar to 0 and Mask to ###-##-####,

Chapter 8 ✦ M ore About Bound Controls

the user will see 000-00-0000 in the field. The user wo uld then o vertype the pro mpt
c harac ters with the appro priate values. No te that if yo u use a value fo r PromptChar
that is also legal in the input mask, then yo u need to set the AllowPrompt pro perty
to TRUE.

Database considerations
When using the Masked Edit c o ntro l as a bo und c o ntro l, yo u need to dec ide whic h
value yo u want to sto re in the database. If yo u set the PromptInclude pro perty to
TRUE, the value in Text pro perty, whic h will inc lude any literal values fro m the
input mask, will be saved in the database. Otherwise, the value fro m the ClipText
pro perty will be used.

Using the DateTimePicker Control
While yo u c an use the TextBox o r the Masked Edit c o ntro ls to enter date and
time values, using the DateTimePicker c o ntro l is a muc h better way. The so le
purpo se o f the DateTimePicker c o ntro l is to help users enter legal date and time
values. Fro m a pro gramming po int o f view, it wo rks just like a TextBox c o ntro l.
Yo u c an use the standard data binding pro perties to c o nnec t it to yo ur database.

Key properties
The DateTimePicker c o ntro l c o ntains all o f the standard pro perties fo und in an
average Ac tiveX c o ntro l, suc h as Top, Left, Width, Height, Enabled, ToolTipText,
etc . Ho wever, there are a few key pro perties that affec t the way the c o ntro l wo rks
(see Table 8-6).

Table 8-6
Key Properties of the DateTimePicker Control
Property

Description

CalendarBackColor

A Long value containing the background color of
the calendar.

CalendarForeColor

A Long value containing the foreground color of
the calendar.
Continued

131

132

Part II ✦ Beginning Database Programming

Table 8-6 (continued)
Property

Description

CalendarTitleBackColor

A Long value containing the background color of
the calendar’s title bar.

CalendarTitleForeColor

A Long value containing the foreground color of
the calendar’s title bar.

CalendarTrailingForeColor

A Long value containing the foreground color for
the dates before and after the current m onth.

CheckBox

A Boolean value. When TRUE, a check box w ill
be displayed next to the value. If not checked,
NULL w ill be returned as Value.

CustomFormat

A String value containing an alternate form at to
display date and/ or tim e values chosen from the
characters listed in Table 8-7. Also, you m ust set
Form at to dtpCustom (3).

Day

A Variant value containing the currently
selected day of m onth.

DayOfWeek

A Variant value containing the currently
selected day of w eek.

Format

An enum erated type specifying the standard or
custom form at that w ill be used to display the
date and/ or tim e value. Possible values are
dtpLongDate (0) to display a date in a long
form at; dtpShortDate (1) to display a date in a
short form at; dtpTime (2) to display the tim e;
and dtpCustom (3) to display the value using the
form at string in CustomFormat.

Hour

A Variant value containing the currently
selected hour.

MaxDate

A Date value containing the m axim um date value
a user can enter.

MinDate

A Date value containing the m inim um date value
a user can enter.

Minute

A Variant value containing the currently
selected m inute.

Month

A Variant value containing the currently
selected m onth.

Chapter 8 ✦ M ore About Bound Controls

Property

Description

Second

A Variant value containing the currently
selected second.

UpDown

A Boolean value w hen TRUE displays an
updow n (spin) button to m odify dates instead of
a drop-dow n calendar.

Value

A Variant value containing the currently
selected date.

Year

A Variant value containing the currently
selected year.

Table 8-7
M ask Characters
Character

Description

D

Displays the day of m onth w ithout a leading zero (1-31).

dd

Displays the day of m onth as tw o digits using a leading zero if
necessary (01-31).

ddd

Displays the day of w eek as a three-character abbreviation ( Sun,
Mon, etc.) .

dddd

Displays the day of w eek w ith its full nam e (Sunday, Monday, etc.).

H

Displays the hour w ithout a leading zero (0-12).

hh

Displays the hour w ith tw o digits, using a leading zero if necessary
(00-12).

H

Displays the hour in 24-hour form at w ithout a leading zero (0-23).

HH

Displays the hour in 24-hour form at, using a leading zero if necessary
(00-23).

M

Displays the m onth w ithout a leading zero (1-12).

MM

Displays the m onth as tw o digits, using a leading zero if necessary
(01-12).

MMM

Displays the m onth as a three-character abbreviation (Jan, Feb, etc.).

MMMM

Displays the m onth w ith its full nam e (January, February, etc.).

m

Displays the m inutes w ithout a leading zero (0-59).
Continued

133

134

Part II ✦ Beginning Database Programming

Table 8-7 (continued)
Character

Description

mm

Displays the m inutes as tw o digits, using a leading zero if necessary
(00-59).

s

Displays the seconds w ithout a leading zero (0-59).

ss

Displays the seconds as tw o digits, using a leading zero if necessary
(00-59).

t

Displays AM or PM as a single character (A or P).

tt

Displays AM or PM as tw o characters (AM or PM).

x

Uses the Callback events ( CallbackKeyDown, Format, and
FormatSize) to get the inform ation needed to form at the custom
date/ tim e value.

y

Displays the day of year (1-365).

yy

Displays the year as a tw o-digit num ber (00-99).

yyyy

Displays the year as a four-digit num ber (0100-9999).

Choosing a user interface
The DateTimePicker c o ntro l has two different ways to allo w users to edit date
and time values. If yo u want to edit o nly date values, yo u c an display a dro p-do wn
c alendar, whic h allo ws the user to selec t a partic ular date ( see Figure 8-4) . Set
UpDown to TRUE.

Figure 8-4: Using a drop-dow n
calendar to enter a date

If yo u want to edit o nly time values o r date and time values, yo u c an set UpDown to
FALSE and the user c an edit by c lic king o n a value and using the spinner arro ws at
the end o f the field to adjust the value (see Figure 8-5). This o ptio n wo rks with all
fo rmats, inc luding any c usto m fo rmat yo u may c ho o se to build.

Chapter 8 ✦ M ore About Bound Controls

Figure 8-5: Entering a date and tim e value

Using the DataCombo Control
The DataCombo c o ntro l lo o ks and wo rks just like a regular ComboBox c o ntro l,
exc ept that the data fo r the c o ntro l c o mes direc tly fro m the datab ase. This c o ntro l is extremely useful when yo u want to translate a c o ded data value into its text
eq uivalent. It uses two datab ase tab les: o ne tab le c o ntaining the data yo u want to
edit, and a translatio n tab le that c o ntains b o th the enc o ded and translated values.
The b eauty o f this c o ntro l is that no c o de is req uired to perfo rm the translatio n
pro c ess.
Note

They come in pairs: The DataList control is very sim ilar to the DataCombo control, in the sam e w ay a list box is the sam e as a com bo box. Thus, they share m any
com m on properties and m ethods.

Key properties
The DataCombo c o ntro l has a number o f pro perties that affec t the way the c o ntro l
wo rks (see Table 8-8). It also suppo rts all o f the standard pro perties, metho ds, and
events listed.

Table 8-8
Key Properties of the DataCombo Control
Property

Description

BoundColumn

A String value that contains the nam e of the colum n that w ill
supply that value to the control.

BoundText

A String value that contains the current value of the
BoundColumn.

DataBindings

An object reference to a DataBindings collection.

ListField

A String value that contains the nam e of the colum n used to
fill the drop-dow n list.

MatchedWithList

A Boolean value that indicates the contents of the BoundText
m atches one of the entries in the list.
Continued

135

136

Part II ✦ Beginning Database Programming

Table 8-8 (continued)

Tip

Property

Description

MatchEntry

An enum erated data type that controls how the user’s
keystrokes w ill be m atched w ith the values in the control. A
value of dblBasicMatching (0) m eans that w hen the user
presses a key, the list of values is searched for by the first item
w hose first character m atches the key that w as pressed. If the
sam e key is pressed again, the second item w hose first character
m atches w ill be displayed. A value of dblExtendedMatching
(1) m eans that the control w ill search for an item in the list
w hose value m atches all of the characters entered. Typing
additional characters refines the search.

RowMember

A String value that identifies w hich set of data should be used
w hen a RowSource has m ore than one set of data.

RowSource

An object reference to an object that can act as a data source.
Com m on data sources include the ADO Data Control, a
Recordset object, or a Class m odule w here the
DataSourceBehavior property is set to vbDataSource (1).

SelectedItem

A Variant value containing a bookm ark for the currently
selected record.

Style

An Integer value that controls how the user interacts w ith the
control. Values are dbcDropdownCombo (0), w hich allow s the
user to enter a value in the text box or select a value from the
drop-dow n box; dbcSimpleCombo (1), w hich allow s the user to
enter a value into the text box or select a value from the list
below the text box; and dbcDropdownList (3), w hich allow s
the user to only select a value from the drop-dow n list.

Sort, please: You should use a Select statem ent w ith the Order By clause w hen
defining your data source so that the list of values can be displayed in sorted
order.

Key methods
The DataCombo c o ntro l suppo rts the usual asso rtment o f metho ds; ho wever, the
ReFill metho d is unique to this and the DataList c o ntro l.

Chapter 8 ✦ M ore About Bound Controls

DataCombo.ReFill ( )
The ReFill metho d gets a fresh c o py o f the data fro m the RowSource and rec reates the list o f items in the list.
Note

It’s not the same: Don’t confuse the ReFill m ethod w ith the Refresh m ethod.
The Refresh m ethod m erely repaints the data on the screen. It doesn’t get a
fresh copy of the data from the database.

Configuring the control
Using the DataCombo c o ntro l is mo re c o mplic ated than mo st bo und c o ntro ls,
bec ause it needs to interac t with two database tables. It also c an be used in two different fashio ns. First, the user may c ho o se a value fro m a list o f values. Sec o nd, the
user may c ho o se fro m a list o f values that are auto matic ally enc o ded and dec o ded
as needed.

Selecting from a list
To func tio n as a no rmal bo und c o ntro l, yo u need to spec ify values fo r bo th the
DataSource and DataField pro perties. The DataSource pro perty must c o ntain
an o bjec t referenc e to an OLE DB data so urc e suc h as an ADO Data Control o r a
Recordset o bjec t that referenc es the table yo u want to update. The DataField
pro perty spec ifies the c o lumn name who se value is displayed in the text part o f
the c o mbo bo x.
The list part o f the c o mbo bo x is po pulated using the RowSource and ListField
pro perties. The RowSource pro perty is an o bjec t referenc e to an ADO Data Control
o r a Recordset o bjec t c o rrespo nding to the list o f entries to be displayed in the list
part o f the c o mbo bo x. The ListField pro perty c o ntains the name o f the c o lumn
who se values will be displayed in the list part o f the c o ntro l. Befo re yo u c an use the
DataCombo c o ntro l, yo u need to set o ne mo re pro perty, BoundColumn. This pro perty
sho uld be set to the same value as ListField.

Translating a value
When designing a datab ase it is c o mmo n to co dify a value in o rder to reduc e
redundanc y in yo ur datab ase. When yo u do this, yo u typic ally c reate a field c alled
Manufac turerId in o ne tab le and use ano ther tab le to translate Manufac turerId
into the manufac turer’s Name. Thus the Manufac turerId value is kno wn as the
co difie d value, while Name is kno wn as the translate d value.

137

138

Part II ✦ Beginning Database Programming

In the example used in this bo o k, eac h ro w in the Invento ry table c o ntains a referenc e
to the Manufac turerId, while the Manufac turers table c o ntains Manufac turerId and
the Name asso c iated with the Manufac turerId. Bec ause Manufac turerId is a numeric
value, it is diffic ult to remember whic h value is asso c iated with eac h manufac turer’s
name. This situatio n is an ideal c andidate fo r the DataCombo c o ntro l.
The pro perties o f the DataCombo c o ntro l sho uld be set as fo llo ws: DataSource =
Ado dc 1 (the table with the raw data); DataField = Manufac turerId (the c o dified
field in the raw data table); RowSource = Ado dc 2 (the translatio n table); ListField
= Name (the translated field in the translatio n table); and BoundColumn =
Manufac turerId (the c o dified field in the translatio n table).
When using the DataCombo c o ntro l to auto matic ally translate a value, yo u sho uld
set the Style pro perty to dbcDropdownList (3) in o rder to prevent pro blems. The
o ther values fo r Style allo w the user to enter their o wn value into the c o ntro l. This
c an c ause a translatio n erro r, sinc e the value in the c o dified c o lumn do esn’t have
translatio n value in the translatio n table. The easiest way to handle this situatio n is
to plac e a butto n beside the DataCombo c o ntro l to add the new value to the translatio n table and then refresh the data displayed in the c o ntro l using the Refill
metho d (see Figure 8-6).

Figure 8-6: Adding a value to the translation table

In the Command2_Click event in the Add New Manufac turer fo rm, whic h o c c urs
when the OK butto n is pressed, yo u begin by adding the new manufac turer to the
Manufac turers table (see Listing 8-4). Then yo u use the Requery metho d to get a
fresh, reo rdered c o py o f the data fro m the database, and then use the data c o mbo ’s
ReFill metho d to get a fresh c o py o f the data fo r the dro p-do wn line. Finally, yo u
sho uld save the newly added manufac turer into the data c o mbo ’s Text pro perty to
save the user fro m having to selec t the newly added info rmatio n.

Chapter 8 ✦ M ore About Bound Controls

Listing 8-4: The Command2_Click event in Inventory
Information —Add New M anufacturer form
Private Sub Command2_Click()
Form1.Adodc2.Recordset.AddNew
Form1.Adodc2.Recordset.Fields(“ManufacturerId”).Value = _
CLng(Text1.Text)
Form1.Adodc2.Recordset.Fields(“Name”).Value = Text2.Text
Form1.Adodc2.Recordset.Update
Form1.Adodc2.Recordset.Requery
Form1.DataCombo1.ReFill
Form1.DataCombo1.Text = Text2.Text
Unload Me
End Sub

Thoughts on Reducing Data Errors
If you w ere to w rite a database program in a different program m ing language, you w ould
probably have to spend a lot of tim e m oving data from database buffers to the various display fields. In som e languages such as COBOL, you m ight spend as m uch as fifty percent of
your program m ing effort w riting this type of code.
By using bound controls in Visual Basic, you can do tw o things. First, you reduce the overall
size of your program , since you don’t have to m ove all that inform ation to and from the
database buffers. Second, you im prove the reliability of your program , since the code that
handles the data m ovem ent isn’t yours. Of course, you m ight m ake a m istake w hen specifying w hich field is associated w ith a particular control, but this is m uch easier to find and
fix than looking through a com plex program and trying to find w hy a particular field w asn’t
updated.
Data validation is a big part of the process also. The best w ay to help prevent your database
from becom ing corrupt is to verify that all of the data that is entered into the database is
acceptable. Using controls such as the MaskedEdit and the DateTimePicker control
m eans that the data that is entered is at least of the right type and the proper form at. This
goes a long w ay tow ards preventing bad data from reaching your database.
Som etim es bad data w ill get into your database no m atter how m uch you check and
recheck your data before it is entered. For instance, som eone could m istype an item num ber yet still end up w ith a bad record. Even though the item num ber w as valid, it w asn’t the
product the custom er w anted. To help prevent this type of problem , you should provide as
Continued

139

140

Part II ✦ Beginning Database Programming

Continued

m uch visual feedback as possible. Perhaps you could display a picture of the item , w hich
w ould allow the custom er to see that they entered the w rong item . Izf a picture isn’t practical, you should at least provide a description of the item from w hich the custom er m ay be
able to recognize their m istake.
While providing feedback isn’t that im portant if the inform ation is being entered by a person w hose full-tim e job is to use this application, it is very im portant for a casual user. A
casual user typically isn’t very com fortable w ith the application and is prone to m aking
m ore m istakes, yet w ith the proper feedback m echanism s, they w ill do a better job in the
long run.

Summary
In this c hapter yo u learned the fo llo wing:

✦ Yo u c an validate data in a bo und c o ntro l by using the Change, KeyPress,
LostFocus, and Validate events.

✦ Yo u c an use the MaskEdit c o ntro l to pro mpt users fo r textual info rmatio n.
✦ Yo u c an use the DateTimePicker c o ntro l to help users selec t date and time
values.

✦ Yo u c an use the DataCombo bo x in plac e o f a no rmal ComboBox c o ntro l to
allo w a user to selec t fro m a series o f values extrac ted direc tly fro m yo ur
database.