|
; 当类只需有一个对象实例(全局对象,比如Application等),必须以Class结尾,如 Class ScreenClass Class SystemClass
iv. 当类只用于作为其他类的基类,根据情况,以Base结尾: MustInherit Class IndicatorBase
v. 如果定义的类是一个窗体,那么名字的后面必须加后缀Form,如果是Web窗体,必须加后缀Page: Class PrintForm : Inherits Form ''''* Windows窗体 Class StartPage : Inherits Page ''''* Web窗体
vi. 模块不是类型,他的名称除了必须以名词命名外,必须加以后缀Module
:Module SharedFunctionsModule
五 设计规范:
5.1对象取值赋给变量或者控件时需要判断对象是否为nothing 例:
If not Customer is Nothing Then
Else
'''' Missing customer data is handled by the account and logon pages
End If
5.2 在使用dataset 对象时 用有意义的常量代替无意义的值 例:
正确的: With Customer.Tables(CustomerData.CUSTOMERS_TABLE).Rows(0)
TxtEmail.Text = CStr(.Item(CustomerData.EMAIL_FIELD))
End With
错误的:With Customer.Tables(0).Rows(0)
TxtEmail.Text = CStr(.Item(0))
TxtEmail.Text = CStr(.Item(“Email”))
End With
5.3 取文本框数值的时候需要去除多余的空格例:
tmpPassword = CountryTextBox.Text.Trim()
5.4 两层嵌套以上的 if else end if 考虑使用 select case 语句 例:
错误的:if DataGrid1.Items(i).Cells(4).Text = "0" Then
ElseIf DataGrid1.Items(i).Cells(4).Text = "1" Then
ElseIf DataGrid1.Items(i).Cells(4).Text = "2" Then
DataGrid1.Items(i).Cells(4).Text = "已培训"
End If
正确的: select Case DataGrid1.Items(i).Cells(4).Text
case “1”
case “2”
case “3”
上一页 [1] [2] [3] [4] 下一页 没有相关教程
|