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

📄 main_frm.frm

📁 模拟的示波器
💻 FRM
📖 第 1 页 / 共 3 页
字号:
                  List            =   "main_frm.frx":0066
                  TabIndex        =   32
                  Text            =   "COM 1"
                  Top             =   720
                  Width           =   1095
               End
               Begin VB.ComboBox comm_baud 
                  Height          =   300
                  ItemData        =   "main_frm.frx":0086
                  Left            =   1125
                  List            =   "main_frm.frx":00AE
                  TabIndex        =   31
                  Text            =   "9600"
                  Top             =   1080
                  Width           =   1095
               End
               Begin VB.CommandButton confirm 
                  Caption         =   "确  定"
                  BeginProperty Font 
                     Name            =   "宋体"
                     Size            =   10.5
                     Charset         =   134
                     Weight          =   700
                     Underline       =   0   'False
                     Italic          =   0   'False
                     Strikethrough   =   0   'False
                  EndProperty
                  Height          =   375
                  Left            =   120
                  TabIndex        =   30
                  Top             =   2760
                  Width           =   975
               End
               Begin VB.CommandButton cancel 
                  Caption         =   "取  消"
                  BeginProperty Font 
                     Name            =   "宋体"
                     Size            =   10.5
                     Charset         =   134
                     Weight          =   700
                     Underline       =   0   'False
                     Italic          =   0   'False
                     Strikethrough   =   0   'False
                  EndProperty
                  Height          =   375
                  Left            =   1320
                  TabIndex        =   29
                  Top             =   2760
                  Width           =   975
               End
               Begin VB.Label Label6 
                  BackStyle       =   0  'Transparent
                  Caption         =   "停止位:"
                  BeginProperty Font 
                     Name            =   "宋体"
                     Size            =   12
                     Charset         =   134
                     Weight          =   400
                     Underline       =   0   'False
                     Italic          =   0   'False
                     Strikethrough   =   0   'False
                  EndProperty
                  ForeColor       =   &H00800080&
                  Height          =   375
                  Left            =   120
                  TabIndex        =   41
                  Top             =   2175
                  Width           =   975
               End
               Begin VB.Label comm_dat 
                  BackStyle       =   0  'Transparent
                  Caption         =   "数据位:"
                  BeginProperty Font 
                     Name            =   "宋体"
                     Size            =   12
                     Charset         =   134
                     Weight          =   400
                     Underline       =   0   'False
                     Italic          =   0   'False
                     Strikethrough   =   0   'False
                  EndProperty
                  ForeColor       =   &H00800080&
                  Height          =   375
                  Left            =   120
                  TabIndex        =   40
                  Top             =   1815
                  Width           =   975
               End
               Begin VB.Label Label4 
                  BackStyle       =   0  'Transparent
                  Caption         =   "校验位:"
                  BeginProperty Font 
                     Name            =   "宋体"
                     Size            =   12
                     Charset         =   134
                     Weight          =   400
                     Underline       =   0   'False
                     Italic          =   0   'False
                     Strikethrough   =   0   'False
                  EndProperty
                  ForeColor       =   &H00800080&
                  Height          =   375
                  Left            =   120
                  TabIndex        =   39
                  Top             =   1470
                  Width           =   975
               End
               Begin VB.Label Label1 
                  BackStyle       =   0  'Transparent
                  Caption         =   "串 口 设 置"
                  BeginProperty Font 
                     Name            =   "宋体"
                     Size            =   12
                     Charset         =   134
                     Weight          =   700
                     Underline       =   0   'False
                     Italic          =   0   'False
                     Strikethrough   =   0   'False
                  EndProperty
                  ForeColor       =   &H00FF0000&
                  Height          =   375
                  Left            =   405
                  TabIndex        =   38
                  Top             =   240
                  Width           =   1575
               End
               Begin VB.Label Label2 
                  BackStyle       =   0  'Transparent
                  Caption         =   "串 口 :"
                  BeginProperty Font 
                     Name            =   "宋体"
                     Size            =   12
                     Charset         =   134
                     Weight          =   400
                     Underline       =   0   'False
                     Italic          =   0   'False
                     Strikethrough   =   0   'False
                  EndProperty
                  ForeColor       =   &H00800080&
                  Height          =   255
                  Left            =   120
                  TabIndex        =   37
                  Top             =   765
                  Width           =   975
               End
               Begin VB.Label Label3 
                  BackStyle       =   0  'Transparent
                  Caption         =   "波特率:"
                  BeginProperty Font 
                     Name            =   "宋体"
                     Size            =   12
                     Charset         =   134
                     Weight          =   400
                     Underline       =   0   'False
                     Italic          =   0   'False
                     Strikethrough   =   0   'False
                  EndProperty
                  ForeColor       =   &H00800080&
                  Height          =   375
                  Left            =   120
                  TabIndex        =   36
                  Top             =   1125
                  Width           =   1095
               End
            End
         End
         Begin MSCommLib.MSComm comm 
            Left            =   6600
            Top             =   3840
            _ExtentX        =   1005
            _ExtentY        =   1005
            _Version        =   393216
            DTREnable       =   -1  'True
            InputMode       =   1
         End
         Begin MSComDlg.CommonDialog file_dialog 
            Left            =   7200
            Top             =   3840
            _ExtentX        =   847
            _ExtentY        =   847
            _Version        =   393216
         End
         Begin VB.Label Cordinate 
            BackColor       =   &H008080FF&
            Caption         =   "坐标"
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   9.75
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            ForeColor       =   &H0000FFFF&
            Height          =   495
            Left            =   6240
            TabIndex        =   2
            Top             =   4440
            Width           =   1695
         End
         Begin VB.Line x_line 
            BorderColor     =   &H0000C0C0&
            X1              =   -3000
            X2              =   8000
            Y1              =   2280
            Y2              =   2280
         End
         Begin VB.Line y_line 
            BorderColor     =   &H0000C0C0&
            X1              =   3960
            X2              =   3960
            Y1              =   -3000
            Y2              =   6000
         End
      End
   End
   Begin VB.Menu file 
      Caption         =   "文件"
      Index           =   1
      Begin VB.Menu open_file 
         Caption         =   "打开文件(O)"
         Shortcut        =   ^O
      End
      Begin VB.Menu excel 
         Caption         =   "excel"
      End
      Begin VB.Menu save_file 
         Caption         =   "保存文件(S)"
         Shortcut        =   ^S
      End
      Begin VB.Menu print_file 
         Caption         =   "打印(P)"
         Shortcut        =   ^P
      End
      Begin VB.Menu close_file 
         Caption         =   "关闭文件(L)"
         Shortcut        =   ^L
      End
      Begin VB.Menu exit_sys 
         Caption         =   "退出(E)"
         Shortcut        =   ^E
      End
   End
   Begin VB.Menu set 
      Caption         =   " 设 置(S)"
      Begin VB.Menu com_set 
         Caption         =   "串口设置"
      End
      Begin VB.Menu mode_select 
         Caption         =   "模式选择"
         Begin VB.Menu oscillograph 
            Caption         =   "示波器模式"
         End
         Begin VB.Menu comm_debug 
            Caption         =   "串口调试模式"
         End
      End
      Begin VB.Menu clear 
         Caption         =   "清空接收缓存"
      End
   End
   Begin VB.Menu help 
      Caption         =   " 帮 助(H)"
      Begin VB.Menu content 
         Caption         =   "内容"
      End
      Begin VB.Menu about 
         Caption         =   "关于软件"
      End
   End
   Begin VB.Menu add_label 
      Caption         =   "添加标签"
      Begin VB.Menu clear_wave 
         Caption         =   "清除图象"
      End
      Begin VB.Menu add_lab 
         Caption         =   "添加标签"
      End
      Begin VB.Menu del_lab 
         Caption         =   "删除标签"
      End
   End
End
Attribute VB_Name = "main_frm"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'**************** 变量定义 **************'
Dim wave_y(800) As Single  '' 波形纵坐标
Dim zoom As Integer        '' 缩放倍数
Dim sing_squ As Single     '' 信号频率
Dim samp_squ As Single     '' 采样频率
Dim sing_unit As String    '' 信号频率单位
Dim samp_unit As String    '' 采样频率单位
Dim lamp_flag As Boolean   '' 串口指示灯状态
Dim number As Long         '' 接收到数据个数
Dim rece_status As Integer '' 接收状态
Dim squ_unit(6) As Integer '' 接收到的频率及单位
Dim rece_num    As Integer '' 接收频率及单位计数
Dim rece_total  As Long    '' 接收总数
Dim wave_num    As Integer '' 波形数据数量

Private Sub cancel_Click()
com_pic.Visible = False

End Sub

Private Sub clear_Click()
receive.Text = ""
End Sub

Private Sub clear_wave_Click()
Call wave_back(20)
For i = 0 To 800 Step 1
    wave_y(i) = 0
Next
End Sub

Private Sub com_set_Click()
com_pic.Visible = True
com_pic.Left = 960
com_pic.Top = 240

End Sub

Private Sub comm_OnComm()
Dim rece As Variant
Dim temp(1) As Byte
With comm
Select Case .CommEvent
       Case comEvReceive
       .RThreshold = 0
       Do
         DoEvents
       Loop Until .InBufferCount >= 1
       rece = .Input
       temp(0) = rece(0)
       If (rece_status = 0) Then
          If (temp(0) = 36) Then rece_status = 1
       ElseIf (rece_status = 1) Then
          If (temp(0) = 67) Then rece_status = 2
       ElseIf (rece_status = 2) Then
          If (temp(0) = 2) Then rece_status = 3
       ElseIf (rece_status = 3) Then
          squ_unit(rece_num) = temp(0)
          rece_num = rece_num + 1
          If (rece_num = 6) Then
             sing_squ = squ_unit(0) * 100 + squ_unit(1)
             samp_squ = squ_unit(3) * 100 + squ_unit(4)
             Select Case squ_unit(2)
                    Case 0: sing_unit = "Hz"
                    Case 20: sing_unit = "KHz"
                    Case 30: sing_unit = "MHz"
             End Select
             Select Case squ_unit(5)
                    Case 26: samp_unit = "Hz"
                    Case 20: samp_unit = "KHz"
                    Case 30: samp_unit = "MHz"
             End Select
             rece_num = 0
             rece_status = 4
         End If
       Else
            wave_y(number) = temp(0)
            receive.Text = receive.Text & wave_y(number) & " "
            rece_total = rece_total + 1
            rece_num = rece_num + 1
            number = number + 1
            If (rece_num = 4) Then
               rece_status = 0
               rece_num = 0
            End If
            If (number = 800) Then
                number = 0
                For i = 0 To 800 Step 1
                    wave_y(i) = 0
                Next

⌨️ 快捷键说明

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