我正在尝试将intptr引用到值(例如,整数),但我没有 找到解决方案
I'm trying to reference an intptr to value (integer, for example), but I don't find the solution
Dim a As Integer = 100 (a = 100) Dim b As IntPtr = a (b = 100) a = 50 (a = 50) b = 100 (b = 100)我想成为50,但我找不到解决方案。 如果我试试,在第一种情况下b真的是a,但不是在第二种情况下。 有没有办法跟踪变量或做类似的事情? 提前致谢 我尝试了什么: 我尝试过活动,包装,甚至所以我找不到解决方案。 有人可以帮助我吗? 最近,谢谢你advance
I want to be 50, but I can't find the solution. If I try that, in the first case b is really a, but not in the second case. Is there any way to track the variables or do something like that? Thanks in advance What I have tried: I have tried with events, wrappers, and even so I can't find the solution. Could anyone help me? Newly, thanks in advance
推荐答案我不确定我是否理解你,但似乎你想跟踪变量。 1.由于一系列原因,跟踪变量很混乱... 2.如果您想了解变量变化,请使用 Class 并在setter中调用事件,例如: I'm not sure i understand you well, but seems you want to track variable changes. 1. Tracking variables is messy for set of reason... 2. If you want to be informed about variable changes, use Class and call event in setter, for example: Public Class myVar Private mValue As Integer Public Event VariableChanged(ByVal mvalue As Integer) Public Property Variable() As Integer Get Variable = mValue End Get Set(ByVal value As Integer) mValue = value RaiseEvent VariableChanged(mValue) End Set End Property End Class
用法:
Usage:
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 = CInt(TextBox1.Text) End Sub Private Sub VariableChanged(ByVal NewValue As Integer) Handles test.VariableChanged MessageBox.Show(NewValue) End Sub End Class以上代码来自: vb - 检测变量变化。 [已解决] | DaniWeb [ ^ ] 如果我错了并且您想在调试时跟踪变量,请使用断点,请参阅:设置变量监视 - Visual Studio | Microsoft Docs [ ^ ]
更多推荐
在VB.NET中引用
发布评论