?? 通訊.frm
字號:
BeginProperty Font
Name = "隸書"
Size = 14.25
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 855
Left = 210
TabIndex = 8
Top = 1485
Width = 3870
Begin VB.OptionButton Option12
Caption = "8"
Height = 420
Left = 300
TabIndex = 12
Top = 345
Value = -1 'True
Width = 615
End
Begin VB.OptionButton Option11
Caption = "7"
Height = 375
Left = 1185
TabIndex = 11
Top = 345
Width = 615
End
Begin VB.OptionButton Option10
Caption = "6"
Height = 375
Left = 2145
TabIndex = 10
Top = 345
Width = 615
End
Begin VB.OptionButton Option9
Caption = "5"
Height = 375
Left = 3030
TabIndex = 9
Top = 345
Width = 615
End
End
Begin VB.Frame Frame1
Caption = "波特率設定"
BeginProperty Font
Name = "隸書"
Size = 14.25
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 1215
Left = 240
TabIndex = 0
Top = 120
Width = 8475
Begin VB.OptionButton Option7
Caption = "19200"
Height = 255
Left = 360
TabIndex = 7
Top = 480
Width = 855
End
Begin VB.OptionButton Option6
Caption = "300"
Height = 255
Left = 7440
TabIndex = 6
Top = 480
Width = 615
End
Begin VB.OptionButton Option5
Caption = "600"
Height = 255
Left = 6360
TabIndex = 5
Top = 480
Width = 615
End
Begin VB.OptionButton Option4
Caption = "1200"
Height = 255
Left = 5280
TabIndex = 4
Top = 480
Value = -1 'True
Width = 735
End
Begin VB.OptionButton Option3
Caption = "2400"
Height = 255
Left = 4200
TabIndex = 3
Top = 480
Width = 735
End
Begin VB.OptionButton Option2
Caption = "4800"
Height = 255
Left = 3000
TabIndex = 2
Top = 480
Width = 735
End
Begin VB.OptionButton Option1
Caption = "9600"
BeginProperty Font
Name = "隸書"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 1680
TabIndex = 1
Top = 360
Width = 735
End
End
Begin MSCommLib.MSComm MSComm1
Left = 2160
Top = 6240
_ExtentX = 1005
_ExtentY = 1005
_Version = 393216
DTREnable = -1 'True
InputLen = 1024
RThreshold = 20
RTSEnable = -1 'True
SThreshold = 10
EOFEnable = -1 'True
End
Begin VB.Label Label1
Caption = "文件選擇"
BeginProperty Font
Name = "隸書"
Size = 14.25
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 735
TabIndex = 33
Top = 6270
Width = 1455
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim 波特率 As String
Dim 數據位 As String
Dim 奇偶校驗 As String
Dim 停止位 As String
Dim 串行口 As Integer
Dim 串行口1 As Integer
Dim 結束符 As String
Dim 交握協議 As Integer
Dim Ls As String
Dim Msg, Style, Title, Help, Ctxt, Response, MyString
Dim Ls1 As Integer
Option Explicit
Public Sub 通訊參數()
If Option1.Value = True Then
波特率 = "9600"
ElseIf Option2.Value = True Then
波特率 = "4800"
ElseIf Option3.Value = True Then
波特率 = "2400"
ElseIf Option4.Value = True Then
波特率 = "1200"
ElseIf Option5.Value = True Then
波特率 = "600"
ElseIf Option6.Value = True Then
波特率 = "300"
ElseIf Option7.Value = True Then
波特率 = "19200"
End If
If Option9.Value = True Then
數據位 = "5"
ElseIf Option10.Value = True Then
數據位 = "6"
ElseIf Option11.Value = True Then
數據位 = "7"
ElseIf Option12.Value = True Then
數據位 = "8"
End If
If Option8.Value = True Then
奇偶校驗 = "E"
ElseIf Option13.Value = True Then
奇偶校驗 = "O"
ElseIf Option14.Value = True Then
奇偶校驗 = "N"
End If
If Option15.Value = True Then
停止位 = "1"
ElseIf Option16.Value = True Then
停止位 = "1.5"
ElseIf Option17.Value = True Then
停止位 = "2"
End If
'===
If Option22.Value = True Then
串行口 = 1
ElseIf Option23.Value = True Then
串行口 = 2
ElseIf Option24.Value = True Then
串行口 = 3
ElseIf 串行口1 > 0 Then
Option22.Value = False
Option23.Value = False
Option24.Value = False
串行口 = 串行口1
End If
If Option18.Value = True Then
交握協議 = 0
ElseIf Option19.Value = True Then
交握協議 = 1
ElseIf Option20.Value = True Then
交握協議 = 2
ElseIf Option21.Value = True Then
交握協議 = 3
End If
If Option26.Value = True Then
結束符 = Chr(26) '& vbCrLf
ElseIf Option27.Value = True Then
結束符 = "OK" '& vbCrLf
End If
MSComm1.Settings = 波特率 & "," & 奇偶校驗 & "," & 數據位 & "," & 停止位
MSComm1.CommPort = 串行口
MSComm1.Handshaking = 交握協議
End Sub
Private Sub Command1_Click()
Dim Msg, Style, Title, Help, Ctxt, Response, MyString
Dim Buffer As String
Dim Ls1 As Integer
Dim ls2 As Long
Dim Ls3 As String
'Open "COM1:" For Input As #2
Open Text1.Text For Output As #3
Ls1 = "1"
通訊參數
MSComm1.PortOpen = True
MSComm1.InputLen = 0
Text2.FontSize = 20
Text2.Text = "計算機已準備好,正在等待來自于COM" & 串行口 & "的數據!"
Cls
Do Until Len(MSComm1.Input) > 0
Buffer$ = Buffer$ & MSComm1.Input
Loop
Text2.FontSize = 10
Text2.Text = "正在接收數據請稍候。。。。。。。。"
Cls
Do
'DoEvents
Buffer$ = Buffer$ & MSComm1.Input
Ls1 = 999
Do Until Ls1 = 0
Ls1 = InStr(Buffer$, vbCrLf)
Text2.Text = Mid(Buffer$, 1, Ls1)
'Text2.Text = Trim(Text2.Text)
' Cls
If Ls1 = 0 Then
Else
Cls
Text2.Text = Text2.Text
Cls
Print #3, Text2.Text
End If
'Buffer$ = Trim(Buffer$)
Buffer$ = Mid(Buffer$, Ls1 + 1)
Loop
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -