📄 form1.frm
字号:
VERSION 5.00
Object = "{648A5603-2C6E-101B-82B6-000000000014}#1.1#0"; "MSCOMM32.OCX"
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.Form Form1
AutoRedraw = -1 'True
Caption = "欢迎使用数据采集系统"
ClientHeight = 8490
ClientLeft = 60
ClientTop = 450
ClientWidth = 13050
LinkTopic = "Form1"
ScaleHeight = 8490
ScaleWidth = 13050
StartUpPosition = 2 '屏幕中心
Begin VB.Timer Timer2
Left = 12240
Top = 6360
End
Begin VB.TextBox Text2
Height = 495
Left = 11400
TabIndex = 9
Top = 3840
Width = 975
End
Begin VB.TextBox Text1
Height = 495
Left = 11400
TabIndex = 8
Top = 2400
Width = 975
End
Begin VB.Timer Timer1
Left = 11520
Top = 6360
End
Begin MSComDlg.CommonDialog CommonDialog1
Left = 12240
Top = 5640
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
Begin MSCommLib.MSComm MSComm1
Left = 11400
Top = 5520
_ExtentX = 1005
_ExtentY = 1005
_Version = 393216
DTREnable = -1 'True
End
Begin VB.Frame Frame1
BackColor = &H00FFC0C0&
Caption = "绘图区"
Height = 6495
Left = 480
TabIndex = 6
Top = 840
Width = 10695
Begin VB.PictureBox Picture1
AutoRedraw = -1 'True
Height = 6135
Left = 120
ScaleHeight = 6075
ScaleWidth = 10395
TabIndex = 7
Top = 240
Width = 10455
End
End
Begin VB.CommandButton Cndtc
Caption = "退 出"
Height = 375
Left = 9240
TabIndex = 5
Top = 7440
Width = 1215
End
Begin VB.CommandButton Cndtz
Caption = "停 止"
Height = 375
Left = 7320
TabIndex = 4
Top = 7440
Width = 1215
End
Begin VB.CommandButton Cndzt
Caption = "暂 停"
Height = 375
Left = 5160
TabIndex = 3
Top = 7440
Width = 1215
End
Begin VB.CommandButton Cnddk
Caption = "打开文件"
Height = 375
Left = 3120
TabIndex = 2
Top = 7440
Width = 1215
End
Begin VB.CommandButton Cndks
Caption = "开 始"
Height = 375
Left = 1320
TabIndex = 1
Top = 7440
Width = 1095
End
Begin VB.Label Label6
Caption = "A"
BeginProperty Font
Name = "Times New Roman"
Size = 10.5
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 12480
TabIndex = 14
Top = 3960
Width = 375
End
Begin VB.Label Label5
Caption = "V"
BeginProperty Font
Name = "Times New Roman"
Size = 10.5
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 12480
TabIndex = 13
Top = 2520
Width = 375
End
Begin VB.Label Label4
Height = 375
Left = 9960
TabIndex = 12
Top = 360
Width = 2535
End
Begin VB.Label Label3
Caption = "电流值"
BeginProperty Font
Name = "隶书"
Size = 14.25
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 11400
TabIndex = 11
Top = 3360
Width = 975
End
Begin VB.Label Label2
Caption = "电压值"
BeginProperty Font
Name = "隶书"
Size = 14.25
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 11400
TabIndex = 10
Top = 1920
Width = 975
End
Begin VB.Label Label1
Alignment = 2 'Center
Caption = "欢迎使用HTD数据采集系统"
BeginProperty Font
Name = "楷体_GB2312"
Size = 24
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FF00FF&
Height = 495
Left = 1200
TabIndex = 0
Top = 120
Width = 9375
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim countdata As Long, countU As Integer, countI As Integer, countpicU As Integer, countpicI As Integer, C As Integer '计数变量
Const divX = 20
Dim data() As Integer, dataU() As Single, dataI() As Single '存储数据变量
Dim Ufar As Single, Ifar As Single, YU As Single, YI As Single, Ix As Integer '绘图变量
Private Sub Cnddk_Click()
On Error GoTo ErrorHandler
CommonDialog1.CancelError = True
'打开对话框
CommonDialog1.DefaultExt = txt
CommonDialog1.Action = 1
ReDim data(0)
countdata = 0
Open CommonDialog1.FileName For Input As #2 '打开数据文件
Do While Not EOF(2)
ReDim Preserve data(countdata)
Input #2, data(countdata) '读取数据
countdata = countdata + 1
Loop
Close #2
Picture1.Cls
Call XoY
countpicU = 0
countpicI = 0
countU = 0
countI = 0
C = 0
Ix = 0
If data(0) < data(1) Then '保存的数据第一个为电流值则删掉
For i = LBound(data) To Int(UBound(data) / 2) - 1 '把数据分离成2路
ReDim Preserve dataU(countU)
ReDim Preserve dataI(countI)
dataU(countU) = data(2 * i + 1)
dataI(countI) = data(2 * i + 2)
countU = countU + 1
countI = countI + 1
Next i
Else
For i = LBound(data) To Int(UBound(data) / 2) - 1 '把数据分离成2路
ReDim Preserve dataU(countU)
ReDim Preserve dataI(countI)
dataU(countU) = data(2 * i)
dataI(countI) = data(2 * i + 1)
countU = countU + 1
countI = countI + 1
Next i
End If
For i = 0 To countU - 1
dataU(i) = dataU(i) * 5 / 255 * 40 '对接收的数据进行处理 扩大40倍还原电压值
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -