[VB.Net]判斷變數是否改變
其實這個功能我找了好久,因為我是從Indusoft撰寫程式跳到真正的程式語言,所以很依賴這個功能,每當某變數有啥變動時,就執行那些指令。 在Google大神下用中文搜尋超久,一直沒有我要的答案。後來用英文的方式搜尋,果真有我要的....這時候真的覺得 會英文真好~~~哈 目前找到的版本如下,有點麻煩~~但還可以接受 Public Class Form1 Private WithEvents test As New myVar Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click test.Variable = TextBox1.Text End Sub Private Sub VariableChanged(ByVal NewValue As String) Handles test.VariableChanged MessageBox.Show(NewValue) End Sub End Class '======類別===== Public Class myVar Private mValue As String Public Event VariableChanged(ByVal mvalue As String) Public Property Variable() As String Get Variable = mValue End Get Set(ByVal value As String) mValue = value RaiseEvent VariableChanged(mValue) End Set End Property End Class