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

📄 form1.frm

📁 曲线绘制程序2曲线绘制程序2曲线绘制程序2曲线绘制程序2曲线绘制程序2曲线绘制程序2曲线绘制程序2
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   4845
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   8715
   LinkTopic       =   "Form1"
   ScaleHeight     =   4845
   ScaleWidth      =   8715
   StartUpPosition =   3  '窗口缺省
   Begin VB.Timer Timer1 
      Left            =   4680
      Top             =   600
   End
   Begin VB.PictureBox Picture1 
      Height          =   1455
      Left            =   600
      ScaleHeight     =   1395
      ScaleWidth      =   2235
      TabIndex        =   0
      Top             =   480
      Width           =   2295
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
    
  Const MAX_VALUE     As Long = 100         '检测的最大值
  Const MIN_VALUE     As Long = -100         '检测的最小值
  Const DeviceHeight     As Long = MAX_VALUE - MIN_VALUE
  Private DeviceWidth     As Long     '显示宽度由   PictureBox1   决定
    
  Private xLast     As Long
  Private yLast     As Long
    
  Function GetNewValue() As Long
          '模拟监控设备的值
          Static v     As Long
            
          v = v + Rnd() * 10 - 5
          If v > MAX_VALUE Then
                  v = MAX_VALUE - (v - MAX_VALUE)
          ElseIf v < MIN_VALUE Then
                  v = MIN_VALUE + (MIN_VALUE - v)
          End If
    
          GetNewValue = v
  End Function
    
  Private Sub Form_Load()
          With Picture1
                  .BorderStyle = vbBSNone
                  DeviceWidth = .Width / Screen.TwipsPerPixelX
                  .Height = DeviceHeight * Screen.TwipsPerPixelY
                    
                  .ScaleMode = vbPixels
                  .BackColor = vbBlack
                  .ForeColor = vbGreen
                  .AutoRedraw = True
                  Picture1.Line (0, MAX_VALUE)-(DeviceWidth, MAX_VALUE), vbYellow
          End With
            
          Timer1.Interval = 100
  End Sub
    
  Private Sub Timer1_Timer()
          Dim x     As Long
          Dim y     As Long
            
          x = xLast + 1
          y = MAX_VALUE - GetNewValue()
          If x >= DeviceWidth Then           '到达右边界,折回
                  x = 0
                  xLast = -1
                  yLast = y
          End If
            
          Picture1.Line (x, 0)-(x, DeviceHeight), vbBlack
          Picture1.PSet (x, MAX_VALUE), vbYellow
          Picture1.Line (x + 1, 0)-(x + 1, DeviceHeight), &H8000&
          Picture1.Line (xLast, yLast)-(x, y)
            
          xLast = x
          yLast = y
  End Sub

⌨️ 快捷键说明

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