📄 test.frm
字号:
_ExtentX = 1005
_ExtentY = 1005
_Version = 393216
DTREnable = -1 'True
End
Begin VB.TextBox Text2
Appearance = 0 'Flat
BackColor = &H8000000F&
BorderStyle = 0 'None
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 8760
TabIndex = 5
Top = 0
Width = 1695
End
Begin VB.CommandButton Command3
Caption = "硬盘数据"
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 3480
TabIndex = 4
Top = 120
Width = 975
End
Begin prjCtlRtCurve.RTCu RTCu1
Height = 6855
Left = 0
TabIndex = 3
Top = 600
Width = 9615
_ExtentX = 16960
_ExtentY = 12091
BackColor = -2147483630
LineColor = 65280
GridColor = 0
HorzSplits = 10
VertSplits = 10
Max = 10
Begin VB.TextBox Text4
Appearance = 0 'Flat
BackColor = &H00000000&
ForeColor = &H000080FF&
Height = 195
Left = 600
TabIndex = 21
Text = "Text4"
Top = 120
Width = 8415
End
End
Begin VB.CommandButton Command2
Caption = "保存数据"
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 240
TabIndex = 1
Top = 120
Width = 1095
End
Begin VB.CommandButton Command1
Caption = "片内数据"
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 1920
TabIndex = 0
Top = 120
Width = 975
End
Begin VB.Timer Timer1
Enabled = 0 'False
Interval = 100
Left = 120
Top = 6960
End
Begin VB.Label Label8
Caption = "0℃"
Height = 375
Left = 9720
TabIndex = 16
Top = 6720
Width = 375
End
Begin VB.Label Label7
Caption = "10℃"
Height = 255
Left = 9720
TabIndex = 15
Top = 5160
Width = 495
End
Begin VB.Label Label6
Caption = "20℃"
Height = 255
Left = 9720
TabIndex = 14
Top = 3600
Width = 375
End
Begin VB.Label Label5
Caption = "30℃"
Height = 255
Left = 9720
TabIndex = 13
Top = 2160
Width = 375
End
Begin VB.Label Label4
Caption = "40℃"
Height = 255
Left = 9720
TabIndex = 12
Top = 720
Width = 375
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private sss As Single
Dim bytInput() As Byte
Dim start As Single
Dim start2 As Single
Dim sec
Dim once
Dim savefg
Dim datact
Dim xdiv As Integer
Dim b As Integer
Private Sub Command2_Click()
If savefg = 0 Then
Command2.Caption = "暂停保存"
savefg = 1
Else
Command2.Caption = "保存数据"
savefg = 0
End If
End Sub
Private Sub Command3_Click()
历史温度数据.Show
End Sub
Private Sub Command5_Click()
On Error GoTo lll3
Form1.MSComm1.PortOpen = False
Call Form_Load
Exit Sub
lll3:
MsgBox "端口打开失败!"
End Sub
Private Sub Form_Load()
On Error GoTo lll2
RTCu1.InitDrawLine
RTCu1.RePaint
RTCu1.GridColor = vbBlack
Timer1.Enabled = True
start = Timer
Combo1.List(0) = "每隔一秒"
Combo1.List(1) = "每隔一分"
Combo1.List(2) = "每隔一时"
Combo1.List(3) = "每隔一天"
Combo1.Text = "每隔一分"
Combo2.List(0) = "慢"
Combo2.List(1) = "正常"
Combo2.List(2) = "快"
Combo2.Text = "正常"
Combo5.List(0) = "COM1"
Combo5.List(1) = "COM2"
Combo5.List(2) = "COM3(USB扩展)"
Select Case Combo5.Text
Case "COM1"
Form1.MSComm1.CommPort = 1
Case "COM2"
Form1.MSComm1.CommPort = 2
Case "COM3(USB扩展)"
Form1.MSComm1.CommPort = 3
End Select
Form1.MSComm1.Settings = "9600,n,8,1"
Form1.MSComm1.PortOpen = True
Form1.MSComm1.RThreshold = 1
Exit Sub
lll2:
MsgBox "COM口不存在,请选择其他端口!"
End Sub
Private Sub Timer1_Timer()
On Error Resume Next
Form1.MSComm1.CommPort = 2
Select Case Combo2.Text
Case "正常"
xdiv = 1
Case "慢"
xdiv = 0
Case "快"
xdiv = 2
End Select
Select Case Form1.MSComm1.CommEvent
Case comEvReceive
Form1.MSComm1.InputMode = comInputModeBinary
bytInput = Form1.MSComm1.Input
End Select
sss = bytInput(0) + bytInput(1) * 0.01
Text1.Text = "温度:" & sss & "℃"
Text4.Text = "一:" & sss & "℃ " & "二:" & sss & "℃ " & "三:" & sss & "℃ " & "四:" & sss & "℃ " & "五:" & sss & "℃ " & "六:" & sss & "℃ " & "七:" & sss & "℃ " & "八:" & sss & "℃ "
RTCu1.AddValue sss / 4, xdiv
RTCu1.RePaint
Text3.Text = "已监控:" & Int(Timer - start) & "秒"
Select Case Combo1.Text
Case "每隔一秒"
sec = Format(Now, "ss")
Case "每隔一分"
sec = Mid(Format(Now, "hh:mm"), 4, 4)
Case "每隔一时"
sec = Format(Now, "hh")
Case "每隔一天"
sec = Format(Now, "DD")
End Select
If Not once = sec And savefg And Not datact = 10000 Then
Open "D:\temprecord.txt" For Append As #1
once = sec
sec = Format(Now, "hh:mm:ss")
datact = datact + 1
Text2.Text = "已保存" & datact & "组数据"
Print #1, "时间:" & sec; " 温度:"; sss; "℃"; vbCrLf
Close #1 '
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -