Public Function Checkstr(Str) If Isnull(Str) Then CheckStr = "" Exit Function End If CheckStr = Replace(Str,"'","''")
End Function 这是一个公有函数,外部可以访问的,调用方法 myclass.Checkstr(Str) 反之如果为私有的,则用Private 取代public 3、属性(Property) 属性分两种,一种是只写属性,一种是只读属性。
也可以为公有或私有,现在以公有为例子。 这是一个只写的属性 Public Property Let Value(ByVal vNewValue) Dim tmpstr tmpstr = vNewValue tmpstr = split(tmpstr,"@@@") html = split(tmpstr(0),"|||") Strings = split(tmpstr(1),"|||") pic = split(tmpstr(2),"|||") End Property 这是一个只读的属性 Public Property Get TodayNum TodayNum = Application(Forum_sn & "_Dv_setup")(9,0) End Property
如果要有读写的属性那么 Public Property Get TodayNum TodayNum = Application(Forum_sn & "_Dv_setup")(9,0) End Property Public Property Let TodayNum(ByVal vNewValue) TodayNum = vNewValue End Property
这样写TodayNum就具有读写的属性了,
方法,也以公有为例, Public Sub TrueCheckUserLogin() 代码 end sub
以下为一个简单的类的的例子: Class cls_templates Public html,Strings,pic Private Sub Class_Initialize()
end sub Private Sub class_terminate()
end sub Public Property Let Value(ByVal vNewValue) Dim tmpstr tmpstr = vNewValue tmpstr = split(tmpstr,"@@@") html = split(tmpstr(0),"|||") Strings = split(tmpstr(1),"|||") pic = split(tmpstr(2),"|||") End Property End Class