涓插彛閫氫俊 VB浠g爜绀轰緥

2021-02-28 18:11 admin

鏉ユ簮: 浣滆€?admin 鍙戣〃鏃堕棿::15 娴忚娆℃暟:銆?/div>
 

涓€涓畝鍗曠殑VB绀轰緥锛屽彲缁忛€傚綋淇敼鎴愪负涓婁綅鏈轰笌鍗曠墖鏈洪€氫俊锛屼篃鑳藉仛鎴愯蒋浠剁儳褰曞櫒锛屽叾瀹冪紪绋嬭瑷€璇硶鍩烘湰鐩镐技銆?/p>


Private Sub Command3_Click()
Dim a() As Byte
ReDim a(3)

a(0) = HA1
a(1) = HA1
a(2) = HA2
a(3) = HA3
MSComm1.Output = a '妯℃嫙鍙戦€佹暟鎹?br>End Sub

Private Sub Form_Load()
MSComm1.CommPort = 1 '璁剧疆涓插彛涓篶om1
MSComm1.Settings = "9600,n,8,1" '閫氳鍙傛暟 娉㈢壒鐜?濂囧伓鏍¢獙 鏁版嵁浣?鍋滄浣?br>MSComm1.InputMode = comInputModeBinary '浜岃繘鍒舵帴鏀?br>MSComm1.PortOpen = True '鎵撳紑涓插彛
MSComm1.InBufferCount = 0 '娓呯┖鎺ユ敹缂撳啿鍖?br>MSComm1.RThreshold = 1 '缂撳啿鍖轰腑鎺ユ敹鍒颁竴涓瓧绗︼紝灏变骇鐢熶竴娆nComm浜嬩欢
End Sub

'鎺ユ敹涓婁綅鏈哄彂閫佺殑鏁版嵁
Private Sub MSComm1_OnComm()
Dim indata As Variant '瀹氫箟鍙橀噺
Dim arr() As Byte '瀹氫箟瀛楄妭鏁扮粍
Dim i As Integer
Select Case MSComm1.CommEvent indata = MSComm1.Input '鎺ユ敹鍒扮殑鏁版嵁瀛樻斁鍒癷ndata閲?
arr = indata '杩斿洖indata鐨勫€?
For i = 0 To UBound(arr)
If Len(Hex(arr(i))) = 1 Then
Text2.Text = Text2.Text "0" Hex(arr(i)) '鍦╰ext2涓樉绀烘暟鎹?
Else
Text2.Text = Text2.Text Hex(arr(i)) '鍦╰ext2涓樉绀烘暟鎹?
End If
Next
MSComm1.InBufferCount = 0 ' 娓呯┖鎺ユ敹缂撳啿鍖?
End Select
End


棣栭〉 涓婁竴椤?鍏盢椤?褰撳墠M椤? 涓嬩竴椤靛熬椤?/div>
鐣欒█璇勮 閫佽姳(鏈€楂?) 铔嬬牳(鏈€楂?) 鎵撻叡娌圭殑銆傘€傘€?閲嶆柊缂栬緫)
404 Data Not Found

鍦板潃:璐靛窞鐪侀摐浠佸競鏉炬瀵ョ殝琛楅亾鍩庡崡瀹㈣繍绔欏皬鍟嗗搧鍩?鏍?灞?25銆?26
鐢佃瘽锛?
绾㈡灄缃?/a>