gpt4 book ai didi

c++ - 将 C++ 代码转换为 VB.net(使用 while)

转载 作者:行者123 更新时间:2023-11-28 05:33:22 24 4
gpt4 key购买 nike

我在将一些 C++ 示例代码解析为 VB.net 时遇到问题(是的,我知道你不会粘贴代码 == 帮我做),但我需要一些指导。

C++ 示例代码:

int busy=1;
while (busy == 1)
{
hr = pMarker ->GetBusyStatus (cardnum ,&busy);
}
busy=1;

hr = pMarker ->MarkObj (cardnum,i,90.0);

VB.net 代码(我有,不能正常工作)

Dim busy As Integer
hr = pMarker.GetBusyStatus(cardnum, busy)

While busy = 1
hr = pMarker.GetBusyStatus(cardnum, busy)
hr = pMarker.MarkObj(cardnum, i, 90.0)
End While

感谢您的帮助!

编辑:

Dim busy As Integer=1

While busy = 1
hr = pMarker.GetBusyStatus(cardnum, busy)
End While

hr = pMarker.MarkObj(cardnum, i, 90.0)

我知道我必须将 busy 用作 ByRef,以便像指针一样使用它...那么,我该如何管理呢?

最佳答案

对于在 VB.NET 中通过引用传递的参数,您需要在方法定义中将其定义为 ByRef - 调用代码中没有任何内容表明它是通过引用(不同于 C++ & 或 C# ref)。您没有显示 GetBusyStatus 的定义,但它应该是这样的:

Public Function GetBusyStatus(cardnum As String, ByRef busy As Integer) As Integer
'...
If someCondition Then
busy = 0
End If
End Function

关于c++ - 将 C++ 代码转换为 VB.net(使用 while),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38894019/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com