小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

vb自定義類模塊并添加事件

 nxhujiee 2019-01-23
類模塊兒和一般常用的控件一樣都是一種對(duì)象,具有事件、屬性等性質(zhì)。因此學(xué)會(huì)創(chuàng)建類模塊兒對(duì)象,在編程中是非常重要的。
下面的自定義模塊兒實(shí)現(xiàn):
增加一個(gè)text屬性;并自動(dòng)驗(yàn)證前后兩次字符串變量是否一致的功能。
在testClass模塊二中添加如下代碼:
Option Explicit
'增加一個(gè)驗(yàn)證字符串事件
Public Event PropertyChanged(ByVal PropName As String, ByVal oldValue As String, ByVal newValue As String)
'聲明變量
Private m_Text As String
'聲明內(nèi)部屬性
'Public Property Get Text() As String
     'Text = m_Text
'End Property

━━━━━━━━━━━━━━━━━━━━━━━━━
'添加事件的調(diào)用
Public Property Let Text(ByVal n_Text As String)
    
If n_Text <> m_Text Then
        Dim 
oldText As String
        
oldText m_Text
        m_Text n_Text
        RaiseEvent PropertyChanged("Text", oldText, n_Text)
    
End If
End Property

━━━━━━━━━━━━━━━━━━━━━━━━━
在窗體中添加如下代碼:
Option Explicit
'聲明具有事件的對(duì)象
Public WithEvents oTest As testClass

Private Sub Form_Load()
    
'實(shí)例化對(duì)象變量,并進(jìn)行兩次賦值
    
Set oTest New testClass
    oTest.Text "123"
    oTest.Text "456"
End Sub

Private Sub 
otest_propertychanged(ByVal PropName As String, ByVal oldValue As String, ByVal newValue As String)
    
'MsgBox  "oTest的屬性 " &; PropName &;  "從 " &; oldValue &;  "變成 " &; newValue &;  " 了! "
    
MsgBox "otest的屬性& ; PropName & ; "從 “ & ; oldValue & ; "” 變成 “& ; newValue & ; "” 了!"
End Sub 
 

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶 評(píng)論公約

    類似文章 更多