📄 form1.frm
字号:
VERSION 5.00
Object = "{648A5603-2C6E-101B-82B6-000000000014}#1.1#0"; "MSCOMM32.OCX"
Begin VB.Form frmcomm
Caption = "通信系统"
ClientHeight = 6165
ClientLeft = 4500
ClientTop = 3135
ClientWidth = 6900
KeyPreview = -1 'True
LinkTopic = "Form1"
MaxButton = 0 'False
ScaleHeight = 6165
ScaleWidth = 6900
Begin VB.Timer Timer2
Interval = 5
Left = 360
Top = 1560
End
Begin VB.OptionButton Option3
Caption = "9600bps"
Height = 495
Left = 5280
TabIndex = 3
Top = 2280
Value = -1 'True
Width = 1215
End
Begin VB.OptionButton Option2
Caption = "4800bps"
Height = 495
Left = 5280
TabIndex = 2
Top = 1800
Width = 1215
End
Begin VB.OptionButton Option1
Caption = "1200bps"
Height = 495
Left = 5280
TabIndex = 1
Top = 1320
Width = 1215
End
Begin VB.Timer Timer1
Interval = 300
Left = 360
Top = 2280
End
Begin MSCommLib.MSComm MSComm1
Left = 360
Top = 2760
_ExtentX = 1005
_ExtentY = 1005
_Version = 393216
DTREnable = -1 'True
End
Begin VB.TextBox txtRcv
Height = 735
Left = 3120
MultiLine = -1 'True
TabIndex = 4
Top = 1560
Width = 1215
End
Begin VB.TextBox txtSend
Height = 735
Left = 1320
MaxLength = 1
TabIndex = 0
Top = 1560
Width = 1095
End
Begin VB.Label Label10
AutoSize = -1 'True
Caption = "红外线传送数据:"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 240
Left = 3240
TabIndex = 14
Top = 3960
Width = 1800
End
Begin VB.Shape Shape1
BackColor = &H0000FF00&
BackStyle = 1 'Opaque
Height = 2000
Left = 2640
Top = 3000
Width = 375
End
Begin VB.Label Label9
AutoSize = -1 'True
Caption = "广东海利集团"
Height = 180
Left = 5280
TabIndex = 13
Top = 5880
Width = 1080
End
Begin VB.Label Label8
AutoSize = -1 'True
Caption = "PC联机PIC"
BeginProperty Font
Name = "宋体"
Size = 18
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FF0000&
Height = 360
Left = 2040
TabIndex = 12
Top = 360
Width = 1620
End
Begin VB.Label Label7
AutoSize = -1 'True
Caption = "OICQ:455022040"
Height = 180
Left = 5280
TabIndex = 11
Top = 5640
Width = 1260
End
Begin VB.Label Label6
AutoSize = -1 'True
Caption = "Designed:孙深炎"
Height = 180
Left = 5280
TabIndex = 10
Top = 5400
Width = 1350
End
Begin VB.Label Label5
AutoSize = -1 'True
Caption = "Label5"
Height = 180
Left = 5280
TabIndex = 9
Top = 5160
Width = 540
End
Begin VB.Label Label4
Caption = "请选择波特率:"
Height = 375
Left = 5280
TabIndex = 8
Top = 960
Width = 1335
End
Begin VB.Label Label3
AutoSize = -1 'True
Caption = "00:00:00"
Height = 180
Left = 5280
TabIndex = 7
Top = 4920
Width = 720
End
Begin VB.Label Label2
Caption = "接收到红外线数据:"
Height = 375
Left = 3120
TabIndex = 6
Top = 1080
Width = 1095
End
Begin VB.Label Label1
Caption = "发送数据 随机函数:"
Height = 375
Left = 1320
TabIndex = 5
Top = 1080
Width = 1095
End
End
Attribute VB_Name = "frmcomm"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim delay As Variant, clk_bord As Variant
Private Sub Command1_Click()
frmcomm.WindowState = vbMinimized
End Sub
Private Sub Command2_Click()
Close #1
End
End Sub
Private Sub Form_KeyPress(KeyAscii As Integer)
If KeyAscii = 27 Then End
End Sub
Private Sub Form_Load()
If Option3.Value = True Then MSComm1.Settings = "9600,n,8"
If Option2.Value = True Then MSComm1.Settings = "4800,n,8"
If Option1.Value = True Then MSComm1.Settings = "1200,n,8"
MSComm1.CommPort = 1 'PORT 1'
MSComm1.InputLen = 1 '一次可以从输入缓冲中输入多少个WORD'
MSComm1.PortOpen = True 'open port'
MSComm1.InputMode = 1 '文本输入'
End Sub
Private Sub Option1_Click()
If Option3.Value = True Then MSComm1.Settings = "9600,n,8"
If Option2.Value = True Then MSComm1.Settings = "4800,n,8"
If Option1.Value = True Then MSComm1.Settings = "1200,n,8"
End Sub
Private Sub Option2_Click()
If Option3.Value = True Then MSComm1.Settings = "9600,n,8"
If Option2.Value = True Then MSComm1.Settings = "4800,n,8"
If Option1.Value = True Then MSComm1.Settings = "1200,n,8"
End Sub
Private Sub Option3_Click()
If Option3.Value = True Then MSComm1.Settings = "9600,n,8"
If Option2.Value = True Then MSComm1.Settings = "4800,n,8"
If Option1.Value = True Then MSComm1.Settings = "1200,n,8"
End Sub
Private Sub Timer1_Timer()
Dim dattemp As String
Dim cc(0) As Byte
Randomize
cc(0) = Rnd * 10
txtSend.Text = cc(0)
MSComm1.Output = cc
Do
DoEvents
Loop Until MSComm1.OutBufferCount = 0
Label3.Caption = Time
Label5.Caption = Date
End Sub
Private Sub Timer2_Timer()
Dim Buffer As Variant, i
MSComm1.InputMode = 1
MSComm1.InputLen = 1
Buffer = MSComm1.Input
For i = LBound(Buffer) To UBound(Buffer)
txtRcv.Text = Buffer(i)
If Buffer(i) > 86 Then Buffer(i) = 85 '防止PIC关机时传来255数据,红外线传递数据最大为85
Shape1.Height = Buffer(i) * 35
Shape1.Top = 6000 - Shape1.Height
Next i
End Sub
Private Sub txtSend_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then cmdcomm.Value = True
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -