VB編程規約
2024-07-21 02:21:00
供稿:網友
 
vb編程規約
jugnlesong
1. 對象命名規約
對象種類
  對象名稱
 對象前綴
 例
 
form  
  窗體
 frm
 frmmain
  
 
mdi 子窗體
  子窗體
 mdi
 mdinote
  
 
picture box
  圖片控件
 pic
 picview
  
 
label
  
  標籤控件
 lbl
 lblmessage
 
text box
  文本控件
 txt
 txtpassword
 
frame
  
  框架控件
 fra
 fraoption
  
 
command button
  命令控件
 cmd
 cmdclose
  
 
check button
  復選框
 chk
 chktaxinclude
 
option button
  單選框
 opt
 optfemale
 
combo box
  複合框
 cbo
 cbogroup
  
 
list box
  列表框
 lst
 lstitems
  
 
horiz sroll bar
  水平滾動條
 hsb
 hsb
  
 
vertical scroll bar
  垂直滾動條
 vsb
 vsbvolume
 
timer
  
  時間控件
 tmr
 tmralarm
  
 
drive list box
  盤符控件
 drv
 drvtarget
 
directory box 目錄控件
 dir
 dirpath
  
 
file list box
  文件列表控件
 fil
 filsource
  
 
shape
  
  shape控件
 shp
 shpcircle
  
 
line
  
  劃線控件
 lin
 linvertical
 
image
  
  圖像控件
 img
 imgicon
  
 
data control
  數據控件
 dat
 datbiblio
  
 
ole control
  ole控件
 ole
 oleexcel
  
 
menu
  
  菜單
 mnu
 mnufile
  
 
 
2. activex控件命名規約
對象種類
 
 對象前綴
 例
  
 
adodc
  
 ado
 adobiblio
  
 
commondialog
 dlg
 dlgfileopen
 
mscomm
 com
 comfax
  
 
datacombo
 dbc
 dbcauthor
 
datagrid
 dgd
 dgdtitles
  
 
datalist
 dbl
 dblpublisher
 
datarepeater
 drp
 drplocation
 
dtpicker
  
  
 dtp
 dtppublished
 
mshflexgrid
 flex
 flexorders
 
mapimessages
 mpm
 mpmsentmessage
 
mapisession
 mps
 mpssession
 
mmcontrol
 mci
 mcivideo
  
 
monthview
  
 mvw
 mvwperiod
 
mschart
  
 ch
 chsalesbyregion
 
msflexgrid
 msg
 msgclients
 
sstab
 mst
 mstfirst
  
 
slider
  
 sld
 sldscale
  
 
statusbar
 sta
 stadatetime
 
sysinfo
 sys
 sysmonitor
 
tabstrip
 tab
 taboptions
 
toolbar
  
 tlb
 tlbactions
 
treeview
 tre
 treorganization
 
updown
 upd
 upddirection
 
 
 
3. dao對象命名規約
對象種類
 對象前綴
 例
  
 
dbengine
  
 dbe
 dbejet
  
 
workspace
 wsp
 wspmain
  
 
database
  
 db
 dbbiblio
  
 
tabledef
  
 tbd
 tbdcustomers
 
querydef
  
 qry
 qryalltitle
 
recordset
 rec
 rectitles
  
 
field
  
 fld
 fldname
  
 
 
4. ado對象命名規約
對象種類
 對象前綴
 例
  
 
connection
 cnn
 cnnoracle
 
command
  
 cmd
 cmdgettitle
 
recordset
 rst
 rsttitles
  
 
parameter
 prm
 prmisbn
  
 
field
  
 fld
 fldcity
  
 
 
5. 基本變量命名規約
變量類型
 前綴
 例子
 
bolean布朗型 
 bln
 blnfound 
 
byte字節型 
 byt
 bytarray 
 
collection 集合型對象 
 col
 coltitle
 
currency貨幣型  
 cur
 curtax
  
 
date日期型
  
 dtm
 dtmbegin
  
 
double雙精度浮點數
 dbl
 dblratio
 
error錯誤
 err
 errlocal
  
 
integer 整數型 
 int
 intquantity
 
long  長整數型
 lng
 lngtotal
  
 
object對象
 obj
 objcurrent
 
single単精度浮點數
 sng
 sngaverage
 
string字符串 
 str
 strusername
 
用戶定義類型 
 udt
 udtemployee
 
variant變體型 
 vnt
 vntbookmark
 
 
 
6. 變量適用範圍前綴命名規約
適用範囲
 プリフィックス
 例
 
全局變量
 g
 gstrusername
 
模塊級變量
 m
 mblndone 
 
局部變量
 なし
 dblprofit 
 
7. 函數前綴命名規約
適用範囲
 プリフィックス
 例
 
sub
  
  
  
  
 
 窗體內
 s
 sgrid_set
  
 
 模塊內
 ms
 msdb_open
 
function
  
  
  
  
 
 窗體內
 f
 fchange_text
 
 模塊內
 mf
 mfkanri_cmb_set
 
8. 通用變量命名
変數內容
 変數名
 屬性
 
返回值
 ret
 integer或者boolean
 
循環變量
 i
 integer 
 
件數
 cnt
 integer 
 
sql命令
 mstrsql
 string(bascommonで定義)