從網上買了一個二維碼讀取器,VB的開發包也要了。卻發現一個問題。
用普通的介面驅動程式連接上,打開一個TXT,然后掃一下,應該是帶回車和換行的,每掃一個碼,游標會自動到下一行的開始處。再就是時間有間隔,掃完一個件,把件還放在掃描儀上,掃碼儀過一秒或半秒種再次掃描一次。用廠方提供的VB的開發包不行了,手拿著件很快的往上一放,就連著掃3下,不厭其煩。好像是掃描速度過快。后來好不容易弄明白了。就是紅字的地方,那個地方把引擎打開了,然后引擎就一直開著,就很高速的掃描。解決方法是得寫一個回圈或是間歇的程式,讓這個引擎一開一關,或是延時運行,讓它減慢掃描的速度。但怎么實作,這研究了三天,實在是沒招了,來向各位前輩求教求教,頓首。
Private bytByte(0 To 2000) As Byte
Private Sub Command1_Click()
ReleaseLostDevice
Unload Me
End Sub
Private Sub Form_Load() '查找設備
If GetDevice = 1 Then
If StartDevice = 1 Then '啟動設備
setQRable 1 '啟動QR引擎
SetBeepTime 1000 '設定掃描蜂鳴聲
Else
MsgBox "啟動設備失敗"
End If
Else
MsgBox "獲取設備失敗"
End If
End Sub
Private Sub Label2_Change()
If Label2 = "85" Then Label1 = "王"
If Label2 = "41" Then Label1 = "望"
If Label2 = "44" Then Label1 = "泰"
If Label2 = "83" Then Label1 = "山"
If Label2 = "64" Then Label1 = "高"
If Label2 = "40" Then Label1 = "日"
If Label2 = "43" Then Label1 = "黃"
If Label2 = "42" Then Label1 = "昭"
If Label2 = "05" Then Label1 = "日"
If Label2 = "61" Then Label1 = "大"
If Label2 = "52" Then Label1 = "所"
If Label2 = "82" Then Label1 = "石"
If Label2 = "45" Then Label1 = "秦"
If Label2 = "84" Then Label1 = "任"
If Label2 = "47" Then Label1 = "地"
If Label2 = "49" Then Label1 = "南"
If Label2 = "63" Then Label1 = "后"
If Label2 = "81" Then Label1 = "小"
If Label2 = "56" Then Label1 = "三"
If Label2 = "50" Then Label1 = "西"
If Label2 = "48" Then Label1 = "兩"
If Label2 = "62" Then Label1 = "萬"
End Sub
Private Sub Text1_Change()
Label2 = Mid(Text1, 9, 2)
Text1.Text = ""
End Sub
'間隔1秒
Private Sub Timer1_Timer()
GetDecodeString bytByte(0)
Text1 = Text1 + ByteToStr(bytByte)
End Sub
uj5u.com熱心網友回復:
后來沒有辦法,只好服氣,又直接用它的通用驅動又做了一個通用驅動版的。(通用驅動版有好處,不用視窗本身呼叫DLL,省事)但是也不行。每次掃描的時候,在label1里邊都讀不出東西來,經過研究發現,是因為用開發包來掃描讀取的時候,是把整串二維碼資訊做為一整條數碼一下子放到TEXT1里邊,所以可以用來提取和識別。而我用通用的驅動是將二維碼掃碼器掃出來的一整串資訊做為鍵盤輸入的資訊,一個字一個字的填上去的。所以每填一個字,就被消掉了,所以在label1里邊什么東西也讀不出來(標示為紅色的那一行)。
現在的問題是,怎么樣才能讓Text1里邊的資訊,在讀取、識別完成之后自動消失,以進行下一條的掃描錄入,又保持Text1的焦點狀態,又能夠讓資訊輸入完成呢。。
Private Sub Command1_Click()
End
End Sub
Private Sub Label2_Change()
If Label2.Caption = "85" Then Label1 = "王"
If Label2.Caption = "41" Then Label1 = "望"
If Label2.Caption = "44" Then Label1 = "泰"
If Label2.Caption = "83" Then Label1 = "山"
If Label2.Caption = "64" Then Label1 = "高"
If Label2.Caption = "40" Then Label1 = "日"
If Label2.Caption = "43" Then Label1 = "黃"
If Label2.Caption = "42" Then Label1 = "昭"
If Label2.Caption = "05" Then Label1 = "日"
If Label2.Caption = "61" Then Label1 = "大"
If Label2.Caption = "52" Then Label1 = "濤"
If Label2.Caption = "82" Then Label1 = "石"
If Label2.Caption = "45" Then Label1 = "秦"
If Label2.Caption = "84" Then Label1 = "任"
If Label2.Caption = "47" Then Label1 = "河"
If Label2.Caption = "49" Then Label1 = "南"
If Label2.Caption = "63" Then Label1 = "后"
If Label2.Caption = "81" Then Label1 = "小"
If Label2.Caption = "56" Then Label1 = "三"
If Label2.Caption = "50" Then Label1 = "西"
If Label2.Caption = "48" Then Label1 = "兩"
If Label2.Caption = "62" Then Label1 = "萬"
End Sub
Private Sub Text1_Change()
Label2 = Mid(Text1, 9, 2)
Text1.Text = ""
Text1.SetFocus
End Sub
uj5u.com熱心網友回復:
不要做A語言代碼修改為B語言代碼的無用功。也不要做用A語言代碼直接呼叫B語言代碼庫這樣復雜、這樣容易出錯的傻事。
只需讓A、B語言代碼的輸入輸出重定向到文本檔案,或修改A、B語言代碼讓其通過文本檔案輸入輸出。
即可很方便地讓A、B兩種語言之間協調作業。
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/131280.html
標籤:VB基礎類
下一篇:vb的textbox在直接粘貼excel單元格,為什么會在字串后面顯示回車符和換行符兩個空白的位元組,求大神解疑!!
