如何用VB6.0通過串口從電子秤中獲取數(shù)據(jù)(源代碼)
Option Explicit Dim strss As String Private Sub Form_Load() MSComm1.CommPort = 1 '串口號, MSComm1.Settings = "9600,n,8,1 " '串口的屬性 MSComm1.InputLen = 0 MSComm1.InputMode = comInputModeText MSComm1.RThreshold = 1 MSComm1.PortOpen = True End Sub Private Sub MSComm1_OnComm() Select Case MSComm1.CommEvent Case comEvReceive strss = strss & MSComm1.Input If Right(strss, 2) = vbCrLf Then Label1.Caption = strss Open "D:\DATA.txt" For Append As #1 Print #1, Mid(strss, 1, Len(strss) - 2) '去除回車換行 Close strss = "" End If End Select End Sub
相關(guān)產(chǎn)品
免責(zé)聲明
- 凡本網(wǎng)注明“來源:化工儀器網(wǎng)”的所有作品,均為浙江興旺寶明通網(wǎng)絡(luò)有限公司-化工儀器網(wǎng)合法擁有版權(quán)或有權(quán)使用的作品,未經(jīng)本網(wǎng)授權(quán)不得轉(zhuǎn)載、摘編或利用其它方式使用上述作品。已經(jīng)本網(wǎng)授權(quán)使用作品的,應(yīng)在授權(quán)范圍內(nèi)使用,并注明“來源:化工儀器網(wǎng)”。違反上述聲明者,本網(wǎng)將追究其相關(guān)法律責(zé)任。
- 本網(wǎng)轉(zhuǎn)載并注明自其他來源(非化工儀器網(wǎng))的作品,目的在于傳遞更多信息,并不代表本網(wǎng)贊同其觀點和對其真實性負(fù)責(zé),不承擔(dān)此類作品侵權(quán)行為的直接責(zé)任及連帶責(zé)任。其他媒體、網(wǎng)站或個人從本網(wǎng)轉(zhuǎn)載時,必須保留本網(wǎng)注明的作品第一來源,并自負(fù)版權(quán)等法律責(zé)任。
- 如涉及作品內(nèi)容、版權(quán)等問題,請在作品發(fā)表之日起一周內(nèi)與本網(wǎng)聯(lián)系,否則視為放棄相關(guān)權(quán)利。