?? 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 + -