分享
 
 
 

Visual Basic 6 Naming Standards

王朝vb·作者佚名  2006-01-08
窄屏简体版  字體: |||超大  

This contains the Microsoft Recommended naming conventions for Objects, and Variables in Visual Basic 6.0.

Why is this here? I believe it is always important to follow some standard when coding, and if your job involves VB programming, then I'm sure you will agree that it definitely makes code easier to read and understand. Most if not all, IT jobs will require you to follow a set of standards while writing your code.

The Visual Basic Coding standards have changed over the years but they are still about the same, with the Scope and Type identifiers to tell if a variable is global, module or local, and what the data type of the variable is. I remember the previous set of standards used only a single character type identifier. (most of the code in this site still uses the old standard, I just have not caught on to the new one yet.) The new standard of the 3 character type identifier makes VB's standards more like that of Visual C++. (I doubt this is coincidence.)

Visual Basic Naming Standards

Control type

prefix

Example

3D Panel

pnl

pnlGroup

ADO Data

ado

adoBiblio

Animated button

ani

aniMailBox

Check box

chk

chkReadOnly

Combo box, drop-down list box

cbo

cboEnglish

Command button

cmd

cmdExit

Common dialog

dlg

dlgFileOpen

Communications

com

comFax

Control (used within procedures when the specific type is unknown)

ctr

ctrCurrent

Data

dat

datBiblio

Data-bound combo box

dbcbo

dbcboLanguage

Data-bound grid

dbgrd

dbgrdQueryResult

Data-bound list box

dblst

dblstJobType

Data combo

dbc

dbcAuthor

Data grid

dgd

dgdTitles

Data list

dbl

dblPublisher

Data repeater

drp

drpLocation

Date picker

dtp

dtpPublished

Directory list box

dir

dirSource

Drive list box

drv

drvTarget

File list box

fil

filSource

Flat scroll bar

fsb

fsbMove

Form

frm

frmEntry

Frame

fra

fraLanguage

Gauge

gau

gauStatus

Graph

gra

graRevenue

Grid

grd

grdPrices

Hierarchical flexgrid

flex

flexOrders

Horizontal scroll bar

hsb

hsbVolume

Image

img

imgIcon

Image combo

imgcbo

imgcboProduct

ImageList

ils

ilsAllIcons

Label

lbl

lblHelpMessage

Lightweight check box

lwchk

lwchkArchive

Lightweight combo box

lwcbo

lwcboGerman

Lightweight command button

lwcmd

lwcmdRemove

Lightweight frame

lwfra

lwfraSaveOptions

Lightweight horizontal scroll bar

lwhsb

lwhsbVolume

Lightweight list box

lwlst

lwlstCostCenters

Lightweight option button

lwopt

lwoptIncomeLevel

Lightweight text box

lwtxt

lwoptStreet

Lightweight vertical scroll bar

lwvsb

lwvsbYear

Line

lin

linVertical

List box

lst

lstPolicyCodes

ListView

lvw

lvwHeadings

MAPI message

mpm

mpmSentMessage

MAPI session

mps

mpsSession

MCI

mci

mciVideo

Menu

mnu

mnuFileOpen

Month view

mvw

mvwPeriod

MS Chart

ch

chSalesbyRegion

MS Flex grid

msg

msgClients

MS Tab

mst

mstFirst

OLE container

ole

oleWorksheet

Option button

opt

optGender

Picture box

pic

picVGA

Picture clip

clp

clpToolbar

ProgressBar

prg

prgLoadFile

Remote Data

rd

rdTitles

RichTextBox

rtf

rtfReport

Shape

shp

shpCircle

Slider

sld

sldScale

Spin

spn

spnPages

StatusBar

sta

staDateTime

SysInfo

sys

sysMonitor

TabStrip

tab

tabOptions

Text box

txt

txtLastName

Timer

tmr

tmrAlarm

Toolbar

tlb

tlbActions

TreeView

tre

treOrganization

UpDown

upd

updDirection

Vertical scroll bar

vsb

vsbRate

Variable Naming Conventions

Visual Basic uses a Scope and Type identifier to prefix each variable name, so it is easy to tell the data type of the variable and where the variable is declared. The Scope can be one of three things:

Scope

Prefix

Example

Global

g

gstrUserName

Module-level

m

mblnCalcInProgress

Local to procedure

None

dblVelocity

The Type identifier follows the Scope identifier and will enable anyone looking at your code to instantly know the data type of all your variables without having to look for the variables declaration. The following is a list of the data types and their prefixes:

Data type

Prefix

Example

Boolean

bln

blnFound

Byte

byt

bytRasterData

Collection object

col

colWidgets

Currency

cur

curRevenue

Date (Time)

dtm

dtmStart

Double

dbl

dblTolerance

Error

err

errOrderNum

Integer

int

intQuantity

Long

lng

lngDistance

Object

obj

objCurrent

Single

sng

sngAverage

String

str

strFName

User-defined type

udt

udtEmployee

Variant

vnt

vntCheckSum

So if you had a global variable named "Counter" and it is a long, you would name the variable "glngCounter" Anyone looking at this variable would instantly know the variable is global to the whole project and would know it is a long. In a multi-developer environment this type of standard is a must, or else there will be considerable time lost while each developer keeps referring to the variable declarations.

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有