VBA命名规范

Element

Naming Convention

Variables

<scope><array><data type>DescriptiveName

Constants

<scope><data type>DESCRIPTIVE_NAME

User-defined types

Type DESCRIPTIVE_NAME
<data type>DescriptiveName
End Type

Enumerations

Enum <project prefix>GeneralDescr
<project prefix>GeneralDescrSpecificName1
<project prefix>GeneralDescrSpecificName2
End Enum


The Scope Specifier (<scope>)

g Public

m Module level

(nothing) Procedure level

The Array Specifier (<array>)

a Array

(nothing) Not an array

The Data Type Specifier (<data type>)

Suggested Naming Convention Prefixes

Prefix

Data Type

Prefix

Data Type

Prefix

Data Type

b

Boolean

cm

ADODB.Command

cbo

MSForms.ComboBox

byt

Byte

cn

ADODB.Connection

chk

MSForms.CheckBox

cur

Currency

rs

ADODB.Recordset

cmd

MSForms.CommandButton

dte

Date

   

ddn

MSForms.ComboBox

dec

Decimal

cht

Excel.Chart

fra

MSForms.Frame

d

Double

rng

Excel.Range

lbl

MSForms.Label

i

Integer

wkb

Excel.Workbook

lst

MSForms.ListBox

l

Long

wks

Excel.Worksheet

mpg

MSForms.MultiPage

obj

Object

   

opt

MSForms.OptionButton

sng

Single

cbr

Office.CommandBar

spn

MSForms.SpinButton

s

String

ctl

Office.CommandBarControl

txt

MSForms.TextBox

u

User-defined type

       

v

Variant

cls

User-defined

class variable

ref

RefEdit Control

   

frm

Userform variable

col

VBA.Collection



Powered by ScribeFire.

posted on 2007-06-01 10:43  BEW  阅读(613)  评论(0)    收藏  举报