Sie sind auf Seite 1von 7

Lesson 5

Visual Basic Conventions, Shortcut Keys and Extensions


Prefixes for Controls
Menus Prefixes
Code Editing Keys
Code Window Keyboard Shortcuts
Objects that get data from the user interface
Visual Basic Filename Extensions

OBJECTIVES:
1.
2.
3.
4.

Familiarize with the object naming conventions


Understand how to execute commands using visual basic short cut keys
Compare and contrast the objects that gets data from user interface
Explore the visual basic filename extensions

Object Naming Conventions


Objects should be named with a consistent prefix that makes it easy to
identify the type of object. Recommended conventions for some of the objects
supported by Visual Basic are listed below.

PREFIXES FOR CONTROLS


Control type
3D Panel
ADO Data
Animated button
Check box
Combo box, drop-down list box
Command button
Common dialog
Communications
Control (used within procedures when the
specific type is unknown)

prefix
pnl
ado
ani
chk
cbo
cmd
dlg
com
ctr

Example
pnlGroup
adoBiblio
aniMailBox
chkReadOnly
cboEnglish
cmdExit
dlgFileOpen
comFax
ctrCurrent

Data
Data-bound combo box
Data-bound grid
Data-bound list box
Data combo
Data grid
Data list
Data repeater
Date picker
Directory list box
Drive list box
File list box
Flat scroll bar
Form
Frame
Gauge
Graph
Grid
Hierarchical flexgrid
Horizontal scroll bar
Image
Image combo
ImageList
Label
Lightweight check box
Lightweight combo box
Lightweight command button
Lightweight frame
Lightweight horizontal scroll bar
Lightweight list box
Lightweight option button
Lightweight text box
Lightweight vertical scroll bar
Line
List box
ListView
MAPI message
MAPI session

dat
dbcbo
dbgrd
dblst
dbc
dgd
dbl
drp
dtp
dir
drv
fil
fsb
frm
fra
gau
gra
grd
flex
hsb
img
imgcbo
ils
lbl
lwchk
lwcbo
lwcmd
lwfra
lwhsb
lwlst
lwopt
lwtxt
lwvsb
lin
lst
lvw
mpm
mps

datBiblio
dbcboLanguage
dbgrdQueryResult
dblstJobType
dbcAuthor
dgdTitles
dblPublisher
drpLocation
dtpPublished
dirSource
drvTarget
filSource
fsbMove
frmEntry
fraLanguage
gauStatus
graRevenue
grdPrices
flexOrders
hsbVolume
imgIcon
imgcboProduct
ilsAllIcons
lblHelpMessage
lwchkArchive
lwcboGerman
lwcmdRemove
lwfraSaveOptions
lwhsbVolume
lwlstCostCenters
lwoptIncomeLevel
lwoptStreet
lwvsbYear
linVertical
lstPolicyCodes
lvwHeadings
mpmSentMessage
mpsSession

MCI
Menu
Month view
MS Chart
MS Flex grid
MS Tab
OLE container
Option button
Picture box
Picture clip
ProgressBar
Remote Data
RichTextBox
Shape
Slider
Spin
StatusBar
SysInfo
TabStrip
Text box
Timer
Toolbar
TreeView
UpDown
Vertical scroll bar

mci
mnu
mvw
ch
msg
mst
ole
opt
pic
clp
prg
rd
rtf
shp
sld
spn
sta
sys
tab
txt
tmr
tlb
tre
upd
vsb

mciVideo
mnuFileOpen
mvwPeriod
chSalesbyRegion
msgClients
mstFirst
oleWorksheet
optGender
picVGA
clpToolbar
prgLoadFile
rdTitles
rtfReport
shpCircle
sldScale
spnPages
staDateTime
sysMonitor
tabOptions
txtLastName
tmrAlarm
tlbActions
treOrganization
updDirection
vsbRate

PREFIXES FOR MENUS


Applications frequently use many menu controls, making it useful to have a
unique set of naming conventions for these controls. Menu control prefixes should
be extended beyond the initial "mnu" label by adding an additional prefix for each
level of nesting, with the final menu caption at the end of the name string. The
following table lists some examples.

Menu caption sequence


File Open
File Send Email
File Send Fax
Format Character
Help Contents

Menu handler name


mnuFileOpen
mnuFileSendEmail
mnuFileSendFax
mnuFormatCharacter
mnuHelpContents

When this naming convention is used, all members of a particular menu


group are listed next to each other in Visual Basics Properties window. In
addition, the menu control names clearly document the menu items to which they
are attached.
VISUAL BASIC SHORTCUT KEYS
CODE EDITING KEYS
Use these key combinations to edit code in the Code window.
Shortcut Keys
CTRL+C
CTRL+X
DELETE or DEL
CTRL+V
CTRL+Z
CTRL+Y
CTRL+DELETE
CTRL+BACKSPACE
SHIFT+F4

SHIFT+F3

SHIFT+TAB
CTRL+N

Description
Copy the selected text to the Clipboard.
Cut the selected text to the Clipboard.
Delete the selected text without placing it on the
Clipboard.
Paste the Clipboard contents at the
insertion point.
Undo the last editing action in the current line.
Cut the current line to the Clipboard.
Delete to the end of the word.
Delete to the beginning of the word.
Find Next: repeat text search down through your code. If
no text search has been done, the Find dialog box is
displayed.
Find Previous: repeat text search up
through your code. If no text search has
been done, the Find dialog box is displayed.
Remove indent.
Insert a blank line above the current line.

CODE WINDOW KEYBOARD SHORTCUTS


You can use the following shortcut keys to access commands in the Code
window.
Shortcut Keys
F7
F2
CTRL+F
CTRL+H
SHIFT+F4
SHIFT+F3
CTRL+DOWN ARROW
CTRL+UP ARROW
SHIFT+F2
CTRL+PAGE DOWN
CTRL+PAGE UP
CTRL+SHIFT+F2
CTRL+HOME
CTRL+END
CTRL+RIGHT ARROW
CTRL+LEFT ARROW
END
HOME
CTRL+Z
CTRL+Y
CTRL+DELETE
TAB
SHIFT+TAB
CTRL+SHIFT+F9
SHIFT+F10

Description
View Code window
View Object Browser
Find
Replace
Find Next
Find Previous
Next procedure
Previous procedure
View definition
Shift one screen down
Shift one screen up
Go to last position
Beginning of module
End of module
Move one word to right
Move one word to left
Move to end of line
Move to beginning of line
Undo
Delete current line
Delete to end of word
Indent
Outdent
Clear all breakpoints
View shortcut menu

OBJECTS THAT GET DATA FROM THE USER INTERFACE


Object

Data

Object Property

0 (Unchecked)

Value

1 (Grayed)

Value

Color dialog box

Long

Color

Combo box

String

Text

Directory list box

String

Path

Drive list box

String

Drive

File list box

String

Filename

Font dialog box

Long

Color

Boolean

FontBold

Boolean

FontItalic

Boolean

FontStrikeThru

Boolean

FontUnderline

String

FontName

Number

FontSize

List box

String

Text

Open dialog box

String

Filename

0 (False)

Value

1 (True)

Value

Save As dialog box

String

Filename

Scrollbars

Integer

Value

Textbox

String

Text

Check box

Radio button

VISUAL BASIC FILENAME EXTENSIONS

Extensions

Descriptions

Contents

BAS

Module File

General procedures

CLS

Class modules

Defines a class (object)

FRM

Form File

Forms, event procedures


And general procedures

OCX

ActiveX control

A prewritten program that extends the


capability of Visual Basic.

VBP

Project File

List of al files (FRM, BAS, and so on) that


makes up a single Visual Basic Program.

VBW

Project Workspace File Contains information that Visual Basic uses


to run your programs.

Das könnte Ihnen auch gefallen