Visual Basic 6 Naming Standards

Visual Basic 专栏收录该内容
17 篇文章 0 订阅

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 typeprefixExample
3D PanelpnlpnlGroup
ADO DataadoadoBiblio
Animated buttonanianiMailBox
Check boxchkchkReadOnly
Combo box, drop-down list boxcbocboEnglish
Command buttoncmdcmdExit
Common dialog dlgdlgFileOpen
Communications comcomFax
Control (used within procedures when the specific type is unknown)ctrctrCurrent
DatadatdatBiblio
Data-bound combo boxdbcbodbcboLanguage
Data-bound griddbgrddbgrdQueryResult
Data-bound list boxdblstdblstJobType
Data combodbcdbcAuthor
Data griddgddgdTitles
Data listdbldblPublisher
Data repeaterdrpdrpLocation
Date pickerdtpdtpPublished
Directory list boxdirdirSource
Drive list boxdrvdrvTarget
File list boxfilfilSource
Flat scroll barfsbfsbMove
FormfrmfrmEntry
FramefrafraLanguage
GaugegaugauStatus
GraphgragraRevenue
GridgrdgrdPrices
Hierarchical flexgridflexflexOrders
Horizontal scroll barhsbhsbVolume
ImageimgimgIcon
Image comboimgcboimgcboProduct
ImageListilsilsAllIcons
LabellbllblHelpMessage
Lightweight check boxlwchklwchkArchive
Lightweight combo boxlwcbolwcboGerman
Lightweight command buttonlwcmdlwcmdRemove
Lightweight framelwfralwfraSaveOptions
Lightweight horizontal scroll barlwhsblwhsbVolume
Lightweight list boxlwlstlwlstCostCenters
Lightweight option buttonlwoptlwoptIncomeLevel
Lightweight text boxlwtxtlwoptStreet
Lightweight vertical scroll barlwvsblwvsbYear
LinelinlinVertical
List boxlstlstPolicyCodes
ListViewlvwlvwHeadings
MAPI messagempmmpmSentMessage
MAPI sessionmpsmpsSession
MCImcimciVideo
MenumnumnuFileOpen
Month viewmvwmvwPeriod
MS ChartchchSalesbyRegion
MS Flex gridmsgmsgClients
MS Tab mstmstFirst
OLE containeroleoleWorksheet
Option buttonoptoptGender
Picture boxpicpicVGA
Picture clipclpclpToolbar
ProgressBarprgprgLoadFile
Remote DatardrdTitles
RichTextBoxrtfrtfReport
ShapeshpshpCircle
SlidersldsldScale
SpinspnspnPages
StatusBarstastaDateTime
SysInfosyssysMonitor
TabStriptabtabOptions
Text boxtxttxtLastName
TimertmrtmrAlarm
ToolbartlbtlbActions
TreeViewtretreOrganization
UpDownupdupdDirection
Vertical scroll barvsbvsbRate

 

 

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:

ScopePrefixExample
GlobalggstrUserName
Module-levelmmblnCalcInProgress
Local to procedureNonedblVelocity

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 typePrefixExample
BooleanblnblnFound
BytebytbytRasterData
Collection objectcolcolWidgets
CurrencycurcurRevenue
Date (Time)dtmdtmStart
DoubledbldblTolerance
ErrorerrerrOrderNum
IntegerintintQuantity
LonglnglngDistance
ObjectobjobjCurrent
SinglesngsngAverage
StringstrstrFName
User-defined typeudtudtEmployee
VariantvntvntCheckSum

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.

  • 0
    点赞
  • 0
    评论
  • 0
    收藏
  • 一键三连
    一键三连
  • 扫一扫,分享海报

相关推荐
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值