使用回调函数时出现问题.视觉基础.net [英] Problem with using callback function. visual basic .net

查看:105
本文介绍了使用回调函数时出现问题.视觉基础.net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hs4.dll库.
控制计算机Handyscope HS4 DIFF的功能


在库的文档中:
-------------------------------------------
使用回调函数DataReady

当有新数据可用时,可以在应用程序中调用. DLL
带有功能指针的必须使用
设置为此功能 SetDataReadyCallback word (TDataReady pAddress)
此例程设置Ready函数指针的说明,该指针将
有新数据可用时调用

输入:pAddress指向具有以下原型的函数的指针:

hs4.dll library created in Delphi.
functions that control a computer Handyscope HS4 DIFF


In the documentation of the library:
-------------------------------------------
Using callback function DataReady

When new data is available, to function in the application Can Be Called. The DLL
Which has a function pointer has to Be Set to this function, using
SetDataReadyCallback word (TDataReady pAddress)
This routines sets the description for the Ready function pointer, Which Will
Be Called When new data is available

input: pAddress a pointer to a function with the Following proto-type:

DataReady void (void)
Return value output;
E_NO_HARDWARE
E_INVALID_VALUE
E_NO_ERRORS



Visual Basic 6.0没问题Visual Basic 6.0

代码如下
在模块中. bas:



visual basic 6.0 there is not a problem visual basic 6.0

The code is as follows
In a module. bas:

Public Declare Function SetDataReadyCallback Lib "hs4.dll" (ByVal pAddress As Long) 
As Integer
Sub DataReadyCallback ()
   Form1.FormDataReadyCallback ''
End Sub


形式为form1:


In the form form1:

Sub FormDataReadyCallback ()
   Dim nError As Integer
   nError = ADC_GetData (Ch1Array (0), Ch2Array (0))
   DisplayPaint
End Sub


如果有按钮,请单击:


In the event of a button click:

Private Sub StreamBtn_Click ()
Dim nError As Integer
nErrorr = SetDataReadyCallback (AddressOf DataReadyCallback)
ADC_Start ''begins to measure the team calling the DataReadyCallback does it work
          ''every time there is a new measure


在Visual Basic .net中,关闭程序
如果有按钮,请单击:


In Visual Basic .net close the program
In the event of a button click:

Dim msg As Integer
msg = SetDataReadyCallback(DataReady)
ADC_Start()


在模块中.


In a module.

Public Declare Function SetDataReadyCallback Lib "hs4.dll" (ByVal pAddress As Long) As Integer
Public Function DataReady() As Integer
    MsgBox("por fin ")
    Return 1
End Function



当我运行程序时,您看到我在运行一条消息
MsgBox("por fin")
程序不再关闭.


我遇到了这个问题,已经三天了,请帮助我,我是世界新手. net



when I run the program you see me running a single message
MsgBox("por fin ")
and no more the program closes.


I''ve been with this problem and three days, help me please I''m new to the world. net

推荐答案

好吧,首先在VB.NET Declare Function SetDataReadyCallback中,参数列表中的Long应该是一个整数.
VB6中的Long是一个32位带符号整数.在VB.NET中,它是一个64位有符号整数.在VB.NET中使用VB6代码时,必须确保将所有对Long的引用替换为Integer.

VB6 Integer也是如此.那是一个16位有符号整数.您必须在VB.NET中将这些Integer引用更改为ShortInt16.
Well, first in the VB.NET Declare Function SetDataReadyCallback, the Long in the parameter list should be an Integer.

A Long in VB6 was a 32-bit signed integer. In VB.NET, it''s a 64-bit signed integer. When using VB6 code in VB.NET, you have to make sure you replace all references to Long with Integer.

The same is true with a VB6 Integer. That was a 16-bit signed integer. You have to change those Integer references to Short or Int16 in VB.NET.


这篇关于使用回调函数时出现问题.视觉基础.net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆