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

📄 form1.frm

📁 vb曲线图源码。可显示监控数据状态。用于工控监控
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   BackColor       =   &H00008000&
   Caption         =   "Form1"
   ClientHeight    =   6450
   ClientLeft      =   60
   ClientTop       =   375
   ClientWidth     =   7530
   LinkTopic       =   "Form1"
   ScaleHeight     =   6450
   ScaleWidth      =   7530
   StartUpPosition =   3  '窗口缺省
   Begin VB.Timer Timer3 
      Interval        =   10
      Left            =   6360
      Top             =   7800
   End
   Begin VB.CommandButton Command2 
      Caption         =   "减"
      Height          =   495
      Left            =   2040
      TabIndex        =   4
      Top             =   7800
      Width           =   735
   End
   Begin VB.CommandButton Command1 
      Caption         =   "加"
      Height          =   495
      Left            =   1080
      TabIndex        =   3
      Top             =   7800
      Width           =   615
   End
   Begin VB.Timer Timer2 
      Interval        =   10
      Left            =   120
      Top             =   7680
   End
   Begin VB.TextBox Text2 
      Height          =   375
      Left            =   4800
      TabIndex        =   2
      Text            =   "1"
      Top             =   7920
      Width           =   975
   End
   Begin VB.TextBox Text1 
      Height          =   375
      Left            =   3600
      TabIndex        =   1
      Text            =   "1"
      Top             =   7920
      Width           =   735
   End
   Begin VB.PictureBox Pic 
      BackColor       =   &H00000000&
      Height          =   7695
      Left            =   480
      ScaleHeight     =   7635
      ScaleWidth      =   11235
      TabIndex        =   0
      Top             =   0
      Width           =   11295
      Begin VB.Line Line1 
         BorderColor     =   &H000000C0&
         X1              =   120
         X2              =   11280
         Y1              =   3840
         Y2              =   3840
      End
   End
   Begin VB.Timer Timer1 
      Interval        =   10
      Left            =   0
      Top             =   0
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Dim DataFromCom As Integer '从串口读过来的实时值
Dim DataFromComLast As Integer '上次的串口值
Dim TimeCount As Integer

Private Sub Command1_Click()
Timer2 = True
Timer3 = False
End Sub

Private Sub Command2_Click()
Timer2 = False
Timer3 = True
End Sub

Private Sub Form_Load()
PicScale Pic '调整图像框的坐标系
PicMidleLine Pic '在图像框中画一条中线
End Sub
Private Sub PicScale(picX As PictureBox) '调整图像框的坐标系
picX.Scale (0, picX.ScaleHeight)-(picX.ScaleWidth, -picX.ScaleHeight)
End Sub

Private Sub PicMidleLine(picX As PictureBox) '在图像框中画一条中线
picX.Line (0, 0)-(picX.ScaleWidth, 0), vbGreen '画出中线
End Sub

Private Sub DrawRealLine(picX As PictureBox, TimeCountX As Integer, DataFromComX As Integer, DataFromComLastX As Integer)

If TimeCountX - 1 > 0 Then
picX.Line ((TimeCountX - 1) * 1, DataFromComLastX)-(TimeCountX * 1, DataFromComX), vbWhite
End If

End Sub

Private Sub Timer1_Timer()
DataFromComLast = Text2
Randomize
DataFromCom = 1 * Rnd
TimeCount = TimeCount + 1
DrawRealLine Pic, TimeCount, DataFromCom, DataFromComLast '画出实时的曲线
End Sub

Private Sub Timer2_Timer()
Text1 = Text1 + 1
Text2 = Text1
End Sub

Private Sub Timer3_Timer()
Text1 = Text1 - 1
Text2 = Text1
End Sub

⌨️ 快捷键说明

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