• 软件测试技术
  • 软件测试博客
  • 软件测试视频
  • 开源软件测试技术
  • 软件测试论坛
  • 软件测试沙龙
  • 软件测试资料下载
  • 软件测试杂志
  • 软件测试人才招聘
    暂时没有公告

字号: | 推荐给好友 上一篇 | 下一篇

Visual Basic 6 Naming Standards

发布: 2007-7-01 21:48 | 作者: admin | 来源: | 查看: 15次 | 进入软件测试论坛讨论

领测软件测试网

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.


延伸阅读

文章来源于领测软件测试网 https://www.ltesting.net/


关于领测软件测试网 | 领测软件测试网合作伙伴 | 广告服务 | 投稿指南 | 联系我们 | 网站地图 | 友情链接
版权所有(C) 2003-2010 TestAge(领测软件测试网)|领测国际科技(北京)有限公司|软件测试工程师培训网 All Rights Reserved
北京市海淀区中关村南大街9号北京理工科技大厦1402室 京ICP备2023014753号-2
技术支持和业务联系:info@testage.com.cn 电话:010-51297073

软件测试 | 领测国际ISTQBISTQB官网TMMiTMMi认证国际软件测试工程师认证领测软件测试网