18.04.2015 Views

ArcGIS Engine Developer Guide

ArcGIS Engine Developer Guide

ArcGIS Engine Developer Guide

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

THE V ISUAL BASIC 6 ENVIRONMENT<br />

The tables below summarize suggested naming<br />

standards for the various elements of your Visual<br />

Basic projects.<br />

Module Type<br />

Form<br />

Class<br />

Standard<br />

Project<br />

Prefix<br />

frm<br />

Name your modules according to the overall<br />

function they provide; do not leave any with<br />

default names (such as “Form1”, “Class1”, or<br />

“Module1”). In addition, prefix the names of<br />

forms, classes, and standard modules with three<br />

letters that denote the type of module, as shown<br />

in the table above.<br />

Control Type<br />

Check box<br />

Combo box<br />

Command button<br />

Common dialog<br />

Form<br />

Frame<br />

Graph<br />

Grid<br />

Image<br />

Image list<br />

Label<br />

List box<br />

List view<br />

Map control<br />

Masked edit<br />

Menu<br />

OLE client<br />

Option button<br />

Picture box<br />

Progress bar<br />

Rich text box<br />

Scroll bar<br />

Slider<br />

Status bar<br />

Tab strip<br />

Text box<br />

Timer<br />

Tool bar<br />

Tree view<br />

cls<br />

bas<br />

prj<br />

Prefix<br />

chk<br />

cbo<br />

cmd<br />

cdl<br />

frm<br />

fra<br />

gph<br />

grd<br />

img<br />

iml<br />

lbl<br />

lst<br />

lvw<br />

map<br />

msk<br />

mnu<br />

ole<br />

opt<br />

pic<br />

pbr<br />

rtf<br />

srl<br />

sld<br />

sbr<br />

tab<br />

txt<br />

tmr<br />

tbr<br />

tvw<br />

As with modules, name your controls according<br />

to the function they provide; do not leave them<br />

with default names since this leads to decreased<br />

maintainability. Use the three-letter prefixes<br />

above to identify the type of control.<br />

USER INTERFACE STANDARDS<br />

Consider preloading forms to increase the responsiveness of your application. Be<br />

careful not to preload too many (preloading three or four forms is fine).<br />

Use resource files (.res) instead of external files when working with bitmap files,<br />

icons, and related files.<br />

Make use of constructors and destructors to set variable references that are only<br />

set when the class is loaded. These are the VB functions: Class_Initialize() and<br />

Class_Terminate() or Form_Load() and Form_Unload(). Set all variables to Nothing<br />

when the object is destroyed.<br />

Make sure the tab order is set correctly for the form. Do not add scroll bars to the<br />

tabbing sequence; it is too confusing.<br />

Add access keys to those labels that identify controls of special importance on the<br />

form (use the TabIndex property).<br />

Use system colors where possible instead of hard-coded colors.<br />

Variable declaration<br />

• Always use Option Explicit (or turn on Require Variable Declaration in the VB<br />

Options dialog box). This forces all variables to be declared before use and,<br />

thereby, prevents careless mistakes.<br />

• Use Public and Private to declare variables at module scope and Dim in local<br />

scope. (Dim and Private mean the same at Module scope; however, using Private<br />

is more informative.) Do not use Global anymore; it is available only for<br />

backward compatibility with VB 3.0 and earlier.<br />

• Always provide an explicit type for variables, arguments, and functions.<br />

Otherwise, they default to Variant, which is less efficient.<br />

• Only declare one variable per line unless the type is specified for each variable.<br />

This line causes count to be declared as a Variant, which is likely to be unintended.<br />

Dim count, max As Long<br />

This line declares both count and max as Long, the intended type.<br />

Dim count As Long, max As Long<br />

These lines also declare count and max as Long and are more readable.<br />

Dim count As Long<br />

Dim max As Long<br />

Parentheses<br />

Use parentheses to make operator precedence and logic comparison statements<br />

easier to read.<br />

Result = ((x * 24) / (y / 12)) + 42<br />

If ((Not pFoo Is Nothing) And (Counter > 200)) Then<br />

Chapter 4 • <strong>Developer</strong> environments • 79

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!