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

📄 form0802.frm

📁 VB实验教程源码
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "画正弦曲线"
   ClientHeight    =   3090
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   4680
   LinkTopic       =   "Form1"
   ScaleHeight     =   3090
   ScaleWidth      =   4680
   StartUpPosition =   3  '窗口缺省
   Begin VB.Timer Timer1 
      Enabled         =   0   'False
      Interval        =   10
      Left            =   4200
      Top             =   1920
   End
   Begin VB.CommandButton Command2 
      Caption         =   "平移曲线"
      Height          =   375
      Left            =   2640
      TabIndex        =   2
      Top             =   2520
      Width           =   1215
   End
   Begin VB.CommandButton Command1 
      Caption         =   "正弦曲线"
      Height          =   375
      Left            =   840
      TabIndex        =   1
      Top             =   2520
      Width           =   1215
   End
   Begin VB.PictureBox Picture1 
      Height          =   1815
      Left            =   720
      ScaleHeight     =   1755
      ScaleWidth      =   3075
      TabIndex        =   0
      Top             =   360
      Width           =   3135
   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 Sub Command1_Click()
'单击正弦曲线按钮
    Timer1.Enabled = True '定时器有效
End Sub

Private Sub Command2_Click()
'单击平移曲线
    Dim m As Integer, n As Integer
    Dim scaleY As Single
    Dim x As Integer, y As Integer
    scaleY = Picture1.ScaleHeight / 4
    For m = -100 To 100 Step 10
        For n = 0 To 360
            Picture1.CurrentX = Picture1.ScaleWidth / 4
            Picture1.CurrentY = Picture1.ScaleHeight / 2 + m
            x = n / 180 * scaleY
            y = Sin(3.14 / 180 * n) * scaleY
            Picture1.PSet Step(x, -y), vbBlue
        Next n
    Next m
End Sub

Private Sub Form_Load()
'装载窗体
    Picture1.AutoRedraw = True
    Picture1.Scale (0, 0)-(640, 480)
    Picture1.Cls
End Sub

Private Sub Timer1_Timer()
'正弦曲线的动画绘制
    Dim x As Integer, y As Integer
    Dim scaleY As Single
    Static i As Integer
    '正弦曲线一半高度为Picture1的四分之一
    scaleY = Picture1.ScaleHeight / 4
    Picture1.CurrentX = 0
    Picture1.CurrentY = Picture1.ScaleHeight / 2
    i = i + 1
    x = i / 180 * scaleY
    y = Sin(3.14 / 180 * i) * scaleY
    Picture1.PSet Step(x, -y), vbRed
    '当画到最右边时重新开始画
    If x >= Picture1.ScaleWidth Then
        Picture1.Cls
        i = 0
    End If
End Sub

⌨️ 快捷键说明

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