在VB.NET中引用

编程入门 行业动态 更新时间:2024-10-26 00:32:23
本文介绍了在VB.NET中引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试将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中引用

本文发布于:2023-11-10 10:43:26,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1575136.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:VB   NET

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!