VC DLL:
BOOL __stdcall LEDShowCharge(byte addr,byte ledaddr,int staytime,int charge);VB :
Declare Function LEDShowCharge Lib "CardPc300.dll" (ByVal Addr As Byte, ByVal ledaddr As Byte, ByVal stattime As Long, ByVal charge As Long) As BooleanPrivate Sub LEDShowCharge_Click()
Dim stattime As Long
Dim charge As Long
Dim test As Byte
stattime = 20
charge = 5
test = 25
If LEDShowCharge(1, 255, stattime, charge) Then
MsgBox ("设置收费成功")
Else
MsgBox ("失败!")
End If
End Sub
结果出现 “错误地参数号或是无效地属性赋值” 的错误。查看LEDShowCharge(1, 255, stattime, charge)的定义时提示说什么被隐藏了。这VB代码是我同事写的,VC DLL是我写的,不知道会不会是我DLL的问题,但是我用VC DELPHI调用的时候都正常啊
BOOL __stdcall LEDShowCharge(byte addr,byte ledaddr,int staytime,int charge);VB :
Declare Function LEDShowCharge Lib "CardPc300.dll" (ByVal Addr As Byte, ByVal ledaddr As Byte, ByVal stattime As Long, ByVal charge As Long) As BooleanPrivate Sub LEDShowCharge_Click()
Dim stattime As Long
Dim charge As Long
Dim test As Byte
stattime = 20
charge = 5
test = 25
If LEDShowCharge(1, 255, stattime, charge) Then
MsgBox ("设置收费成功")
Else
MsgBox ("失败!")
End If
End Sub
结果出现 “错误地参数号或是无效地属性赋值” 的错误。查看LEDShowCharge(1, 255, stattime, charge)的定义时提示说什么被隐藏了。这VB代码是我同事写的,VC DLL是我写的,不知道会不会是我DLL的问题,但是我用VC DELPHI调用的时候都正常啊
2、如果DLL已经导出出现这个问题,把VB的声明返回参数用long 替换boolean试试
Declare Function LEDShowCharge Lib "CardPc300.dll" (ByVal Addr As Byte, ByVal ledaddr As Byte, ByVal stattime As Long, ByVal charge As Long) As Long---------------------------C:
#define TRUE 1
#define FALSE 0BOOL = int
bool = byteVB:
True = -1
False = 0Boolean = byte
不过我觉得VB代码看起来好乱啊,不太喜欢VB呵呵
谢谢各位了