?? com.frm
字號(hào):
VERSION 5.00
Object = "{648A5603-2C6E-101B-82B6-000000000014}#1.1#0"; "MSCOMM32.OCX"
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 7260
ClientLeft = 60
ClientTop = 450
ClientWidth = 4665
LinkTopic = "Form1"
ScaleHeight = 7260
ScaleWidth = 4665
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command3
Caption = "接收"
Height = 375
Left = 480
TabIndex = 6
Top = 3120
Width = 615
End
Begin VB.CommandButton Command2
Caption = "發(fā)射"
Height = 375
Left = 600
TabIndex = 5
Top = 1440
Width = 495
End
Begin VB.CommandButton Command1
Caption = "清零"
Height = 375
Left = 600
TabIndex = 4
Top = 720
Width = 495
End
Begin VB.TextBox Text2
Enabled = 0 'False
Height = 2655
Left = 480
TabIndex = 3
Top = 4320
Width = 3855
End
Begin VB.TextBox Text1
Height = 3015
Left = 1320
MultiLine = -1 'True
TabIndex = 0
Top = 480
Width = 3015
End
Begin MSCommLib.MSComm MSComm1
Left = 240
Top = 2280
_ExtentX = 1005
_ExtentY = 1005
_Version = 393216
DTREnable = -1 'True
InputLen = 1
RThreshold = 1
SThreshold = 1
EOFEnable = -1 'True
InputMode = 1
End
Begin VB.Label Label2
Caption = "wrong code:"
Height = 255
Left = 240
TabIndex = 2
Top = 3960
Width = 1215
End
Begin VB.Label Label1
Caption = "full is 512 byte:"
Height = 255
Left = 1320
TabIndex = 1
Top = 120
Width = 1815
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Form_Activate()
'MSComm1.EOFEnable = True
'MSComm1.PortOpen = True
With MSComm1
.CommPort = 1
.Settings = "9600,n,8,1"
.InputLen = 0
.RThreshold = 1
.PortOpen = True
End With
End Sub
Private Sub MSComm1_OnComm()
On Error GoTo err001
Dim GetChar As String
Select Case MSComm1.CommEvent
Case comEventOverrun '數(shù)據(jù)丟失。
Text2.Text = "數(shù)據(jù)丟失!" + "錯(cuò)誤"
Case comEventBreak ' 收到 Break。
Case comEventCDTO ' CD (RLSD) 超時(shí)。
Text2.Text = " CD (RLSD) 超時(shí)。!" + "錯(cuò)誤"
Case comEventCTSTO ' CTS Timeout。
Text2.Text = "CTS Timeout" + "錯(cuò)誤"
Case comEventDSRTO ' DSR Timeout。
Text2.Text = "DSR Timeout。" + "錯(cuò)誤"
Case comEventFrame ' Framing Error
Text2.Text = "Framing Error" + "錯(cuò)誤"
Case comEventOverrun '數(shù)據(jù)丟失。
Text2.Text = "數(shù)據(jù)丟失。!" + "錯(cuò)誤"
Case comEventRxOver '接收緩沖區(qū)溢出。
Text2.Text = "接收緩沖區(qū)溢出!" + "錯(cuò)誤"
Case comEventRxParity ' Parity 錯(cuò)誤。
Text2.Text = "Parity 錯(cuò)誤!" + "錯(cuò)誤"
Case comEventTxFull '傳輸緩沖區(qū)已滿。
Text2.Text = "傳輸緩沖區(qū)已滿!" + "錯(cuò)誤"
Case comEventDCB '獲取 DCB] 時(shí)意外錯(cuò)誤
Text2.Text = "獲取 DCB] 時(shí)意外錯(cuò)誤!" + "錯(cuò)誤"
Case comEvReceive ' 收到數(shù)據(jù)
' 接收數(shù)據(jù)
' 對(duì)數(shù)據(jù)進(jìn)行處理
If MSComm1.InBufferCount Then
GetChar = MSComm1.Input
End If
Text1.Text = Text1.Text + GetChar
'執(zhí)行某一函數(shù)(省略)
Case .comEvSend
'發(fā)送數(shù)據(jù)
Case .comEventRxParity
'對(duì)奇偶校驗(yàn)錯(cuò)誤進(jìn)行處理
End Select
Exit Sub
err001:
MsgBox Err.Description, vbCritical, "錯(cuò)誤"
End Sub
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -