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

📄 form1.frm

📁 一款简易的示波器程序
💻 FRM
📖 第 1 页 / 共 2 页
字号:
      Caption         =   "125us"
      Height          =   240
      Index           =   1
      Left            =   1800
      TabIndex        =   10
      Top             =   5370
      Width           =   1275
   End
   Begin VB.Label Label1 
      Caption         =   "125us"
      Height          =   240
      Index           =   0
      Left            =   135
      TabIndex        =   9
      Top             =   5370
      Width           =   1275
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Private Sub Check1_Click(Index As Integer)
    If Check1(0).Value = 1 Then
        Check1(0).Caption = "红色光标"
    Else
        Check1(0).Caption = "紫色光标"
    End If
End Sub

Private Sub Command1_Click()
    Call Key_run
End Sub

Private Sub Command10_Click()
    If Key_pause = True Then
        Command10.Caption = "连续截图"
    Else
        Command10.Caption = "单一截图"
    End If
    Key_pause = Not Key_pause
End Sub

Private Sub Command11_Click()
    Dim H As Double
    Dim b, i As Double
    Call Picture2show
    Key_HightNum = Key_HightNum + 1
    For i = Show_Num To Showbuff - 1
        If (Showdata(i) And &H80) = &H80 Then
            H = H + 1
            If H >= Key_HightNum Then
               b = (Showdata(i) And &H7F) * 125
               Label1(2).Caption = "第" & H & "个高电平宽度为" & b & "us"
               Exit For
            End If
        End If
    Next i
            
End Sub

Private Sub Command2_Click()
    If TSize < 100 Then
        TSize = TSize * 2
        Slider1.Value = Slider1.Max / 2
        Slider2.Value = Slider2.Max / 2
    End If
    Call Show_label
    If Bkeydown = False Then
        Call Picture2show
    End If
    Bkey_view = True
End Sub

Private Sub Command3_Click()
    If TSize >= 0.01 Then
        TSize = TSize / 2
        Slider1.Value = Slider1.Max / 2
        Slider2.Value = Slider2.Max / 2
    End If
    Call Show_label
    If Bkeydown = False Then
        Call Picture2show
    End If
    Bkey_view = True
End Sub

Private Sub Command4_Click()
    TSize = 4
    Slider1.Max = 100
    Show_Num = 0
    Bkey_view = False
End Sub

Private Sub Command5_Click()
    SavePicture Picture1.Image, App.Path & "\" & picnum & ".BMP"
    picnum = picnum + 1
End Sub

Private Sub Command6_Click()
    If Check1(0).Value = 1 Then
        If Line1.X2 <= 9980 Then
            Line1.X2 = Line1.X2 + 20
            Line1.X1 = Line1.X2
            Line3.X2 = Line1.X2
            Line3.X1 = Line1.X2
        End If
    Else
        If Line2.X2 <= 99980 Then
            Line2.X2 = Line2.X2 + 20
            Line4.X2 = Line2.X2
            Line2.X1 = Line2.X2
            Line4.X1 = Line2.X2
        End If
    End If
    Label1(0).Caption = "△" & Abs(Line2.X2 - Line1.X2) * 125 / TSize / 1000 & "ms"
End Sub

Private Sub Command7_Click()
    If Check1(0).Value = 1 Then
        If Line1.X2 > 19 Then
            Line1.X2 = Line1.X2 - 20
            Line1.X1 = Line1.X2
            Line3.X2 = Line1.X2
            Line3.X1 = Line1.X2
        End If
    Else
        If Line2.X2 > 19 Then
            Line2.X2 = Line2.X2 - 20
            Line4.X2 = Line2.X2
            Line2.X1 = Line2.X2
            Line4.X1 = Line2.X2
        End If
    End If
    Label1(0).Caption = "△" & Abs(Line2.X2 - Line1.X2) * 125 / TSize / 1000 & "ms"
End Sub

Private Sub Command8_Click()
    RightArrow = True
    Leftarrow = False
    Call Ctrl_View
    Call Picture2show
End Sub

Private Sub Command9_Click()
    Leftarrow = True
    RightArrow = False
    Call Ctrl_View
    Call Picture2show
End Sub

Private Sub Form_Load()
    Timer1.Interval = 100
    Timer1.Enabled = True
    TSize = 4
    Slider1.Value = 50
    Slider2.Value = 50
    Call Slider1_Change
    Call Slider2_Change
    Line1.Visible = False
    Line2.Visible = False
    Line3.Visible = False
    Line4.Visible = False
    Picture1.Visible = True
    Picture2.Visible = False
    
    
    Bkeydown = False
    Call Command1_Click
    Picture1.AutoRedraw = False
    ReDim Fdata(0)
    ReDim Showdata(255) As Byte
    Call INIT
    Call Startmscomm
    Call Show_label
    Command11.Enabled = False
    Command12.Enabled = False
    
    Option1(0).Value = True
    Combo1.AddItem 1
    Combo1.AddItem 2
    Combo1.AddItem 4
    Combo1.AddItem 8
    Combo1.AddItem 16
    Combo1.AddItem 32
    Combo1.AddItem 64
    Combo1.AddItem 128
End Sub

Private Sub MSComm1_OnComm()
Dim bytInput() As Byte
Dim intInputLen As Integer
        
    Select Case MSComm1.CommEvent                                           '通讯错误或事件发生时都会产生 OnComm 事件
        
         Case comEventRxOver
                MSComm1.InputMode = comInputModeBinary                       '通过 Input 属性以二进制方式检取回数据
                intInputLen = 0                                                         '是指调制解调器已接收,并在接收缓冲区等待被取走的字符数。可以把 InBufferCount 属性设置为 0 来清除接收缓冲区。

                ReDim bytInput(intInputLen)                                             '以inputlen字符数来重新定义BUINPUT
                bytInput = MSComm1.Input

        
        Case comEvReceive                                       '收到 Rthreshold 个字符
                Form1.Timer1.Enabled = False
                If Not MSComm1.PortOpen Then
                    MSComm1.CommPort = intPort                   '设置并返回通讯端口号
                    MSComm1.Settings = strSet                    '以字符串的形式设置并返回波特率、奇偶校验、数据位、停止位
                    MSComm1.PortOpen = True                      '打开串口
                End If
                
        Form1.MSComm1.InputMode = comInputModeBinary
        intInputLen = Form1.MSComm1.InBufferCount
        ReDim bytInput(intInputLen)
        bytInput = Form1.MSComm1.Input
                
        Call InputManage(bytInput, intInputLen)
        Call GetDisplayText

    End Select
     Form1.Timer1.Enabled = True
End Sub

Private Sub Option1_Click(Index As Integer)
If Not Form1.MSComm1.PortOpen Then
    Form1.MSComm1.CommPort = intPort
    Form1.MSComm1.Settings = strSet
    Form1.MSComm1.PortOpen = True
End If
End Sub

Private Sub Slider1_Change()
    Line1.Visible = True
    Line2.Visible = True
    Line3.Visible = True
    Line4.Visible = True
    Line1.X2 = Slider1.Value / Slider1.Max * 10000
    Line1.X1 = Line1.X2
    Line3.X1 = Line1.X1
    Line3.X2 = Line3.X1
    Label1(0).Caption = "△" & Abs(Line2.X2 - Line1.X2) * 125 / TSize / 1000 & "ms"
End Sub

Private Sub Slider2_Change()
    Line1.Visible = True
    Line2.Visible = True
    Line3.Visible = True
    Line4.Visible = True
    Line2.X2 = Slider2.Value / Slider2.Max * 10000
    Line2.X1 = Line2.X2
    Line4.X2 = Line2.X1
    Line4.X1 = Line4.X2
    Label1(0).Caption = "△" & Abs(Line2.X2 - Line1.X2) * 125 / TSize / 1000 & "ms"
End Sub

'输出线段
Private Sub Timer1_Timer()
    Call Line_Out
End Sub

Private Sub Picture2show()
    Call Picture2_Show
End Sub

Private Sub Show_label()
Dim a As Double
    a = 125 / TSize * 25                                        'AMEND tsiza=4
    If a > 1000 Then
        Label1(1).Caption = a / 1000 & "ms"
    Else
        Label1(1).Caption = a & "us"
    End If
End Sub

⌨️ 快捷键说明

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