Hatena::Groupvb6

VB6メモ

[VB] [個人メモ] [仕事メモ] [アイデア] [Rubyの魔神]
[VB6クラス]
 | 

2017-05-19

Event

AlarmInteger クラス側

Public Event Over(ByVal value As Integer, cancel As Boolean)

Private mvarCurrentValue As Integer 'ローカル コピー
Private mvarMax As Integer 'ローカル コピー
Public Property Let Max(ByVal vData As Integer)
    mvarMax = vData
End Property


Public Property Get Max() As Integer
    Max = mvarMax
End Property



Public Property Let CurrentValue(ByVal vData As Integer)
    Dim cancel As Boolean
    
    If vData > Max Then
        RaiseEvent Over(ByVal vData, cancel)
        If cancel Then Exit Property
    End If
    
    mvarCurrentValue = vData

End Property


Public Property Get CurrentValue() As Integer
    CurrentValue = mvarCurrentValue
End Property

Dim WithEvents X As AlarmInteger

Private Sub Command1_Click()

    X = Text1.Text
    MsgBox (X)
    
    
End Sub

Private Sub Form_Load()
    Set X = New AlarmInteger
    X.Max = 100
End Sub

Private Sub X_Over(ByVal overValue As Integer, cancel As Boolean)
    Dim Answer As VbMsgBoxResult
    
    Answer = MsgBox(overValue & "を代入しようとしています.キャンセルしますか", vbYesNo)
    If Answer = vbYes Then cancel = True
    
    
End Sub

ゲスト



トラックバック - http://vb6.g.hatena.ne.jp/garyo/20170519
 |