|
This question should be used to assess the skills of a junior
level Visual Basic programmer. This is a common problem in
Visual Basic applications. A candidate with 1 year of experience
with Visual Basic should be able to answer the following question
correctly .
 |
You
support an application developed by another programmer
for an aircraft parts company. The client would like
the background on the textbox to be highlighted in yellow
when a textbox receives focus to aid the data entry
people.
How
can this be accomplished?
|
a.
Set the highlightcolor property to yellow in the textbox properties
section.
b.
Set the backcolor in the textboxes GotFocus and LostFocus
events (see the following code fragment):
Private
Sub txtText3_GotFocus()
txtText3.BackColor = vbYellow
End Sub
Private
Sub txtText3_LostFocus()
txtText3.BackColor = vbWhite
End Sub
c.
Set the backcolor in the textboxes GotFocus event (see the
following code fragment):
Private
Sub txtText3_GotFocus()
txtText3.BackColor = vbYellow
End Sub
d.
Set the highlightcolor variable to yellow in the form's highlight
property.
Answers:
The
correct answer is b. Add code to the GotFocus and LostFocus
events of the text controls. This would need to be done for
each of the textboxes that you wanted to highlight when selected.
a.
Incorrect. There is no highlightcolor property for the textbox
object. Someone selecting this answer is guessing and most
likely has never dealt with this common problem in visual
basic.
c.
Partially incorrect. This will highlight the box but never
clear it when focus is lost. Someone selecting this answer
is on the right track but not giving then entire answer.
d.
Incorrect. There is no highlightcolor property for the form
object. Someone selecting this answer is guessing and most
likely has never dealt with this common problem in Visual
Basic.
About
the author
Mark Horninger, A+, MCSE+I, MCSE, MCSD, MCDBA, MCSA is President
and founder of Haverford Consultants Inc. (http://www.haverford-consultants.com),
located in the suburbs of Philadelphia, PA. He develops custom
applications and system engineering solutions, specializing
primarily in Microsoft operating systems and Microsoft BackOffice
products. He has over 15 years of computer consulting experience
and has passed 31 Microsoft Certification Exams. During his
career Mark has worked on many extensive and diverse projects
including database development, client server and web-based
application development, training, embedded systems development
and Windows NT and 2000 project rollout planning and implementations.
Mark is a contributing author to the books: MCSE Windows
2000 Professional Study Guide, Designing SQL Server 2000 Databases
for .NET Enterprise Servers, VB .NET Developers Guide and
Configuring and Troubleshooting Windows XP Professional.
Mark lives with
his wife Debbie and three children in Havertown, Pa. and can
be reached at mark@haverford-consultants.com
or markh@op.net.
|