[VB6 ] 如何用VB接收USB傳的值並存成文字檔
'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
Visual_Basic 近期熱門文章
PTT數位生活區 即時熱門文章