📄 form1.frm
字号:
VERSION 5.00
Object = "{648A5603-2C6E-101B-82B6-000000000014}#1.1#0"; "MSCOMM32.OCX"
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 6975
ClientLeft = 60
ClientTop = 345
ClientWidth = 11670
LinkTopic = "Form1"
ScaleHeight = 6975
ScaleWidth = 11670
StartUpPosition = 3 'Windows Default
Begin VB.CommandButton Command1
Caption = "Command1"
Height = 495
Left = 4920
TabIndex = 1
Top = 4920
Width = 1335
End
Begin VB.Timer Timer1
Interval = 1000
Left = 2160
Top = 6000
End
Begin VB.TextBox Text1
Height = 2175
Left = 3600
TabIndex = 0
Top = 1680
Width = 4215
End
Begin MSCommLib.MSComm MSComm1
Left = 4680
Top = 6240
_ExtentX = 1005
_ExtentY = 1005
_Version = 393216
CommPort = 2
DTREnable = -1 'True
InputMode = 1
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim i As Integer
Dim a() As Byte
Private Sub Command1_Click()
Dim length As Long
Dim j As Long
Dim count As Long
count = 0
Open "c:\save1.dat" For Binary As #1
length = LOF(1)
Get #1, 1, a
Close #1
For j = LBound(a) To UBound(a)
count = count + a(j)
Next
Text1.Text = "the count=" & Str(count) & Chr(13) & Chr(10)
Text1.Text = Text1.Text & "the counter=" & Str(length) & Chr(13) & Chr(10)
Text1.Text = Text1.Text & "count/counter=" & Str(count / length)
End Sub
Private Sub Form_Load()
MSComm1.PortOpen = True
i = 0
End Sub
Private Sub Form_Unload(Cancel As Integer)
If MSComm1.PortOpen Then MSComm1.PortOpen = False
End Sub
Private Sub MSComm1_OnComm()
a = MSComm1.Input
Open "c:\save1.dat" For Binary As #1
Put #1, LOF(1), a
Close #1
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -