作者gguueesstt (..........)
看板Visual_Basic
标题[VB6 ] 如何用VB接收USB传的值并存成文字档
时间Thu Mar 6 19:17:38 2008
'newdll有四个api函式
'opendevice : 开始与HID装置通讯
'Writedevice : 传送资料到HID装置
'Readdevice : 从HID装置接收资料
'closedevice : 结束与HID装置通讯
Public hid As New newdll
Const MyVendorID = &H1234
Const MyProductID = &H5678
Dim Timeout As Boolean
Private Sub Command1_Click()
Dim hiddevice As Boolean
Dim send(7) As Byte
Dim recevice() As String
hiddevice = hid.opendevice(MyVendorID, MyProductID)
Text1.Text = hiddevice
If hiddevice = True Then
send(0) = Val(Text2.Text)
send(1) = Val(Text4.Text)
hid.Writedevice send()
Timeout = False
Timer1.Enabled = True
Timer1.Interval = 50
Do
DoEvents
Loop Until Timeout = True
recevice() = hid.Readdevice
Text3.Text = recevice(2)
End If
hid.closedevice
End Sub
Private Sub text2_KeyPress(KeyAscii As Integer)
If (Chr$(KeyAscii) Like "[!A-Fa-f0-9]") Then KeyAscii = 0
End Sub
Private Sub timer1_Timer()
Timeout = True
Timer1.Enabled = False
End Sub
问题1:
.我是用USB传输资料给VB端的recevice(2)这个阵列做接收(这个阵列的数值是一直在改变
的),但是不知道要怎麽样把这个阵列接收到的数值存成文字档存在电脑中。
问题2:
我想把command1的形式改成用timer的形式,让程式执行後就自动利用timer的功能自动计
数然後执行。
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.118.4.227