Newsletter Tips & Code - June 2000
These tips were extracted from the June 2000 issue of the Visual Basic Explorer
newsletter and were submitted by John Smiley. Be sure to check out John's other
tutorials in the tutorials section or check out his website here.
You can direct any questions, comments or suggestions to the VB Forums section
of this site. Many of the more interesting or frequently asked questions will
end up in one of our newsletter issues.
'-------------------------------------------
Where have you gone Crystal Reports?
Crystal Reports, the leading third party Report Writer for Visual Basic, was previously packaged with VB
in versions 4 and 5 and appeared as an Add-in off of the Visual Basic menu.
VB6 users were disappointed to find that Crystal Reports apparently was not shipped with VB6---most
likely, it was believe, because Microsoft decided to include a Report Writer of its own called the Microsoft
Data Report designer.
For those of you still yearning for Crystal Reports, take heart--you can still find it on your Visual Basic
installation CD-ROM, provided, that is, you purchase Visual Basic Pro or Enterprise.
To find it, look in the
\Common\Tools\CryReports
folder on your installation CD.
'-------------------------------------------
Access Key for a Textbox
Most Visual Basic programmers are familiar with how to designate an access or hot key for a Command
Button. An Access key allows the user to `click` on the control by pressing the Alternate Key plus a letter.
For instance, if you have a Command Button whose caption is OK, to designate a hot key combination of
Alternate+O for the Command Button, you specify
&OK
as the Caption property for the Command Button.
But what a shortcut to get to a Textbox?
The user can click on the textbox or tab to it, but wouldn't it be great to be able to get to a Textbox by
pressing the Alternate key plus a character?
Well, as it turns out, there is.
The secret is to place a label control next to a textbox, and then designate a hot key combination for the
label control using the ampersand character in the Caption property of the label control. For instance, if
you have a textbox sitting next to a label control whose Caption Property is &Name, if the user presses
Alternate+N, focus will move to the textbox adjacent to the label control.
Just one word of warning. In order for this to work, the Textbox's TabIndex property must be immediately
after the TabIndex Property of the Label Control. If the Label Control's TabIndex property is 15, for
instance, the Textbox must be 16.
'-------------------------------------------
Textbox selection goes away
Have you noticed that if the user selects text in a textbox, and then moves focus off of the textbox, that the
text is no longer selected.
This is because the HideSelect property of the textbox is by default set to True.
If you would prefer to keep the text selected when the user moves `off` of the textbox, then just set the
HideSelect property of the Textbox to False.
'-------------------------------------------
Password Char
Have a textbox into which you want the user to type an entry, but don't want anyone looking over their
shoulder to see it.
Just set the PasswordChar Property of the textbox to something other than its default blank character.
For instance, if you set the PasswordChar Property to an asterisk(*), then whatever the user enters into the
Textbox will appear as asterisks.
'-------------------------------------------
The Click event requires both the Mouse Down and Mouse Up over the control
Just a reminder that in order for the Click event procedure of a control to take place, the user must both
click and then release the mouse button over the control. If, after clicking the mouse over the control they
then move it over the form or over another control before releasing it, the click event procedure never
takes place.
'-------------------------------------------
Entries in a Listbox
Many beginners are confounded with the List Property of a Listbox, which is where the programmer can,
at design time, place items that are to appear in a Listbox.
Why are they confounded?
Because when they type an item into the Listbox, invariably they hit the ENTER key, and the List
Property in the Properties Window closes. They select it again, make a second entry, and then hit ENTER
again. Once again, the List property closes. This continues on and on until they have finished adding all
of the items (experienced programmers use the AddItem Method of the Listbox at runtime.).
If you want to add items to a Listbox at design time using the List property, after making your first entry,
type the
Ctrl+N
combination instead of the hitting the ENTER key. This will advance the carriage return to the next line
in the List property, and enable you to more quickly add the items to the Listbox.
Downloads
In IE right-click and select 'Save Target As...' or in Netscape
right-click and select 'Save Link As...'
View Plain Text
Not Available
Not Available