我想在var.NET更改时在VB.NET中做一个If。例如:
If var testvar change do this if Then
Me.RichTextBox1.Text = "Hello World"
End If
答案 0 :(得分:1)
您要做的是创建一个Class来包装您的变量,以及一个在变量发生变化时引发的事件。例如,您的监听器(Form)订阅该事件并对其做出响应。
Imports System
Class MyClass
Private x As Integer
Public Sub SetX(ByVal i As Integer)
x = i
End Sub
Public Function GetX() As Integer
Return x
End Function
Public Event Changed(ByVal sender As Object, ByVal e As EventArgs)
Protected Overridable Sub OnChanged(ByVal e As EventArgs)
RaiseEvent Changed(Me, e)
End Sub
End Class
有关详细信息,请参阅此处。
http://www.codeproject.com/Articles/5041/Step-by-Step-Event-handling-in-VB-NET http://msdn.microsoft.com/en-us/library/ms172877(v=vs.80).aspx