📄 hostlink.frm
字号:
VERSION 5.00
Object = "{648A5603-2C6E-101B-82B6-000000000014}#1.1#0"; "MSCOMM32.OCX"
Begin VB.Form Form1
Caption = " 上 位 机 通 讯 程 序"
ClientHeight = 5448
ClientLeft = 60
ClientTop = 348
ClientWidth = 6648
ForeColor = &H000000FF&
LinkTopic = "Form1"
ScaleHeight = 5448
ScaleWidth = 6648
StartUpPosition = 3 'Windows Default
Begin VB.CommandButton 停止通讯
Caption = "停 止通讯"
Height = 492
Left = 4920
TabIndex = 11
Top = 1200
Width = 1332
End
Begin VB.Timer Timer1
Interval = 1000
Left = 5760
Top = 360
End
Begin VB.OptionButton Option1
Caption = "com2"
Height = 375
Left = 3480
TabIndex = 9
Top = 1080
Width = 2295
End
Begin VB.OptionButton com1
Caption = "com1"
Height = 495
Left = 3480
TabIndex = 8
Top = 480
Value = -1 'True
Width = 2175
End
Begin VB.CommandButton Command2
BackColor = &H00FF8080&
Caption = "清除"
Height = 375
Left = 1680
TabIndex = 7
Top = 4680
Width = 1335
End
Begin VB.TextBox Text3
BackColor = &H00C0C0FF&
Height = 852
Left = 1680
MultiLine = -1 'True
TabIndex = 6
Top = 3600
Width = 3015
End
Begin VB.TextBox Text2
BackColor = &H00FFFFC0&
Height = 375
Left = 1680
TabIndex = 3
Top = 360
Width = 1215
End
Begin MSCommLib.MSComm MSComm1
Left = 360
Top = 1200
_ExtentX = 995
_ExtentY = 995
_Version = 393216
DTREnable = -1 'True
RThreshold = 1
ParitySetting = 2
DataBits = 7
StopBits = 2
End
Begin VB.TextBox Text1
BackColor = &H80000018&
ForeColor = &H80000001&
Height = 972
Left = 1680
MultiLine = -1 'True
TabIndex = 1
Top = 2040
Width = 3015
End
Begin VB.CommandButton Command1
Caption = " 通 讯按 钮"
Height = 495
Left = 1680
TabIndex = 0
Top = 1200
Width = 1335
End
Begin VB.Frame Frame1
Caption = "端口设定"
Height = 1455
Left = 3120
TabIndex = 10
Top = 240
Width = 1575
End
Begin VB.Label Label3
Caption = "发送数据"
Height = 495
Left = 240
TabIndex = 5
Top = 3840
Width = 1215
End
Begin VB.Label Label2
Caption = "FCS校验"
Height = 255
Left = 240
TabIndex = 4
Top = 480
Width = 975
End
Begin VB.Label Label1
Caption = "接收数据"
Height = 255
Left = 240
TabIndex = 2
Top = 2280
Width = 1215
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub com1_Click()
MSComm1.CommPort = 1
End Sub
Private Sub Command1_Click()
Me.Timer1.Enabled = True
End Sub
Private Sub Command2_Click()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
End Sub
Private Sub Form_Load()
Text3.Text = "@00RD05000001"
End Sub
Private Sub MSComm1_OnComm()
Select Case MSComm1.CommEvent
Case comEvReceive
temp = temp & MSComm1.Input
If temp <> "" Then Text1.Text = Text1.Text + temp
Me.Refresh
End Select
End Sub
Private Sub Option1_Click()
If Me.MSComm1.PortOpen = True Then
Me.MSComm1.PortOpen = False
End If
MSComm1.CommPort = 2
End Sub
Private Sub Timer1_Timer()
Dim FcsResult As String
Dim StrIn As String
Dim jytemp As Integer
Dim temp As String
jytemp = 0
StrIn = Text3.Text
Text1.Text = ""
'************** 校 验
For i = 1 To Len(StrIn)
jytemp = Asc(Mid$(StrIn, i, 1)) Xor jytemp
Next i
FcsResult = Hex$(jytemp)
'**************
Text2.Text = FcsResult
If (MSComm1.PortOpen = False) Then MSComm1.PortOpen = True
MSComm1.Output = Text3.Text + Text2.Text + "*" + Chr(13)
End Sub
Private Sub 停止通讯_Click()
Me.Timer1.Enabled = False
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -