我把termb.dll文件复制到了狐表目录下,在全局代码中定义API函数IniComm,格式如下:
Private Declare Function CVR_InitComm Lib "termb.dll" (ByVal Port As Integer) As Integer
Public Function InitComm() As Boolean '遍历串口,端口查找设备。找到返回True
For i As Integer = 1 To 4
If CVR_InitComm(i) = 1 Then Return True
Next
For i As Integer = 1001 To 1004
If CVR_InitComm(i) = 1 Then Return True
Next
Return False
End Function
在窗口中做了个按钮,其click事件代码为:
if InitComm()= true then
messagebox.show("设备已经启动")
end if
可是系统提示如图:是全局代码中定义错了还是事件代码中写错了呢?
此主题相关图片如下:111.jpg