⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄

📁 详细介绍M8两版间通讯
💻
字号:
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   735
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   2940
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   735
   ScaleWidth      =   2940
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton Command1 
      Caption         =   "暂停"
      Height          =   495
      Index           =   1
      Left            =   1440
      TabIndex        =   1
      Top             =   120
      Width           =   1095
   End
   Begin MSComDlg.CommonDialog CommonDialog1 
      Left            =   1080
      Top             =   0
      _ExtentX        =   847
      _ExtentY        =   847
      _Version        =   393216
   End
   Begin VB.CommandButton Command1 
      Caption         =   "开始"
      Height          =   495
      Index           =   0
      Left            =   360
      TabIndex        =   0
      Top             =   120
      Width           =   1095
   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 Counter As 频率计
Private SavePath As String
Private MeasTime(1 To 20) As Date, Agilent(1 To 20) As Currency, EE3386(1 To 20) As Currency
Private Halt As Boolean
Private FSO As FileSystemObject
'定义3组数组,用来记录20组测试数据

Private Sub Command1_Click(Index As Integer)
Dim currTemp As Currency
Dim i As Integer, RelayTime As Long
Select Case Index
  Case 0
  CreateFile
  Command1(0).Enabled = False
  Command1(1).Enabled = True
  Do
    For i = 1 To 20
      Do
        DoEvents
        If Me.Visible = False Then
          End
          Exit Sub
        End If
      Loop Until Halt = False
      MeasTime(i) = Now
      Counter.活动通道 = 1
      currTemp = Counter.读取频率
      EE3386(i) = currTemp
      'Counter.活动通道 = 2
      'currTemp = Counter.读取频率
      Agilent(i) = currTemp
      Delay 500
    Next
    SaveData SavePath
    For i = 1 To 20 * 60
      Delay 1000, False
      If GetInputState Then
        DoEvents
      End If
      If Me.Visible = False Then
        End
        Exit Sub
      End If
    Next
  Loop
  Case 1
  If Halt = True Then
    Command1(1).Caption = "暂停"
    Halt = False
    Else
    Command1(1).Caption = "继续"
    Halt = True
  End If
End Select
End Sub

Private Sub Form_Load()
Set Counter = New 频率计
Counter.面板显示 = False
Counter.闸门时间 = 0.02

Set FSO = New FileSystemObject
Set FSO = CreateObject("Scripting.FileSystemObject")
End Sub

Private Sub Form_Unload(Cancel As Integer)
Set Counter = Nothing
Set FSO = Nothing
End Sub

Private Sub CreateFile()
Dim strTemp As String
' 设置“CancelError”为 True
CommonDialog1.CancelError = True
On Error GoTo ErrHandler
' 设置标志
CommonDialog1.Flags = cdlOFNHideReadOnly
' 设置过滤器
CommonDialog1.Filter = "Text Files(*.txt)|*.txt"
' 指定缺省的过滤器
CommonDialog1.FilterIndex = 1
' 显示“打开”对话框
CommonDialog1.ShowSave
' 显示选定文件的名字
strTemp = CommonDialog1.FileName
'MsgBox strTemp
SavePath = strTemp
FSO.CreateTextFile strTemp
Exit Sub
ErrHandler:
' 用户按了“取消”按钮
End Sub
Private Sub SaveData(FilePath As String)

Dim TxtFile As File, TxtStream As TextStream ' _
                                            定义文件系统对象,文件对象,文本流对象
Dim strTemp As String, i As Integer
'On Error GoTo errLine:

Set TxtFile = FSO.GetFile(FilePath) '对文本对象进行赋值
Set TxtStream = TxtFile.OpenAsTextStream(ForAppending) '重定义文本流变量为写入方式

For i = 1 To 20
  strTemp = strTemp & MeasTime(i) & vbTab & Agilent(i) & vbTab & EE3386(i) & vbCrLf
Next
TxtStream.Write strTemp
TxtStream.Close '关闭文本流对象
Set TxtStream = Nothing
Set TxtFile = Nothing '卸载文本对象
Exit Sub
errLine:
Select Case Err.Number
  Case Else
  MsgBox ""
  Resume
End Select
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -