?? frmcomm.frm
字號:
VERSION 5.00
Object = "{648A5603-2C6E-101B-82B6-000000000014}#1.1#0"; "MSCOMM32.OCX"
Begin VB.Form frmComm
Caption = "數(shù)據(jù)傳輸"
ClientHeight = 4755
ClientLeft = 60
ClientTop = 345
ClientWidth = 4695
LinkTopic = "Form1"
ScaleHeight = 4755
ScaleWidth = 4695
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton cmdStart
Caption = "啟 動"
Height = 615
Left = 1800
TabIndex = 6
Top = 3240
Width = 1095
End
Begin MSCommLib.MSComm MSComm1
Left = 3720
Top = 2280
_ExtentX = 1005
_ExtentY = 1005
_Version = 393216
DTREnable = -1 'True
RThreshold = 1
End
Begin VB.CommandButton cmdReturn
Caption = "返 回"
Height = 615
Left = 3120
TabIndex = 5
Top = 3240
Width = 1095
End
Begin VB.CommandButton cmdOutput
Caption = "發(fā) 送"
Height = 615
Left = 480
TabIndex = 4
Top = 3240
Width = 1095
End
Begin VB.TextBox txtInput2
Height = 375
Left = 2880
TabIndex = 3
Text = "0"
Top = 1680
Width = 855
End
Begin VB.TextBox txtInput1
Height = 375
Left = 2880
TabIndex = 2
Text = "0"
Top = 1080
Width = 855
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "請輸入Y軸上的點數(shù):"
BeginProperty Font
Name = "宋體"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 210
Left = 720
TabIndex = 1
Top = 1800
Width = 1995
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "請輸入X軸上的點數(shù):"
BeginProperty Font
Name = "宋體"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 210
Left = 720
TabIndex = 0
Top = 1200
Width = 1995
End
End
Attribute VB_Name = "frmComm"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub cmdOutput_Click()
msg1$ = "輸入不能為空或0"
msg2$ = "輸入超出范圍"
msg3$ = "通信有誤,請測試串口"
Title1$ = "輸入有誤"
Title2$ = "通信錯誤"
MSComm1.PortOpen = True
MSComm1.Output = Str(2)
While (MSComm1.InBufferCount = 0)
Wend
If (MSComm1.Input <> "A") Then
MsgBox msg3, 0, Title2
GoTo Toend
End If
If (txtInput1.Text = "") Or (txtInput1.Text = 0) Or _
(txtInput2.Text = "") Or (txtInput2.Text = 0) Then
MsgBox msg1, 0, Title1
GoTo Toend
End If
If (txtInput1.Text > 20) Or (txtInput2.Text > 20) Then
MsgBox msg2, 0, Title1
GoTo Toend
End If
MSComm1.Output = txtInput1.Text
MSComm1.Output = "A"
MSComm1.Output = txtInput2.Text
MSComm1.Output = "A"
Toend:
End Sub
Private Sub cmdReturn_Click()
If MSComm1.PortOpen Then MSComm1.PortOpen = False
frmComm.Hide
frmMain.Show
End Sub
Private Sub cmdStart_Click()
If Not MSComm1.PortOpen Then MSComm1.PortOpen = True
MSComm1.Output = Str(3)
MSComm1.PortOpen = False
End Sub
Private Sub Form_Load()
MSComm1.CommPort = sPort
MSComm1.Settings = sBoud
MSComm1.InputLen = 0
txtInput1.Text = MSComm1.CommPort
End Sub
Private Sub MSComm1_OnComm()
If MSComm1.Input = "B" Then
MsgBox "通信成功!", 0, "通信"
MSComm1.Output = "B"
Else
MsgBox "請檢測端口,再發(fā)一次!", 0, "通信"
End If
If MSComm1.PortOpen Then MSComm1.PortOpen = False
End Sub
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -