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

📄 驻波的形成.frm

📁 驻波的形成演示,visual basic
💻 FRM
📖 第 1 页 / 共 2 页
字号:
         ForeColor       =   &H00FFFF80&
         Height          =   255
         Left            =   240
         TabIndex        =   10
         Top             =   720
         Width           =   1335
      End
      Begin VB.Label Label1 
         Caption         =   "向左行进的波"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   10.5
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00FFFF80&
         Height          =   375
         Left            =   240
         TabIndex        =   9
         Top             =   480
         Width           =   1455
      End
   End
   Begin VB.Timer Timer1 
      Interval        =   10
      Left            =   1920
      Top             =   4680
   End
   Begin VB.Menu showMnu 
      Caption         =   "showMnu"
      Visible         =   0   'False
      Begin VB.Menu readMe 
         Caption         =   "课件说明…"
      End
      Begin VB.Menu about 
         Caption         =   "关于本课件…"
      End
      Begin VB.Menu k1 
         Caption         =   "-"
      End
      Begin VB.Menu toLeft 
         Caption         =   "显示向左的行波"
         Checked         =   -1  'True
      End
      Begin VB.Menu toRight 
         Caption         =   "显示向右的行波"
         Checked         =   -1  'True
      End
      Begin VB.Menu both 
         Caption         =   "显示合成波"
         Checked         =   -1  'True
      End
      Begin VB.Menu k2 
         Caption         =   "-"
      End
      Begin VB.Menu step 
         Caption         =   "单步"
      End
      Begin VB.Menu pause 
         Caption         =   "暂停"
      End
      Begin VB.Menu change 
         Caption         =   "显示修改参数对话框"
         Checked         =   -1  'True
      End
      Begin VB.Menu k3 
         Caption         =   "-"
      End
      Begin VB.Menu exitThis 
         Caption         =   "退出程序"
      End
   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 pi As Single = 3.1415926
   Public x0 As Integer, y0 As Integer  '初始坐标原点
   Public xx As Integer, yy As Integer  '保存鼠标坐标
   Public le As Boolean, ri As Boolean, su As Boolean   '鼠标击键标志
   Public leftA As Integer, leftT As Integer, leftJ As Integer, leftL As Integer    '左行波的振幅、周期、初相角、波长
   Public rightA As Integer, rightT As Integer, rightJ As Integer, rightL As Integer    '右行波的振幅、周期、初相角、波长
   Public timeCount As Long  '时间计数器
   Public boll1X As Integer, boll2X As Integer, boll As Integer
   Public boll1 As Boolean, boll2 As Boolean
   
Sub draw()
   Dim i As Integer, s As Single
   Dim y11 As Single, y12 As Single
   Dim y21 As Single, y22 As Single
   Dim y31 As Single, y32 As Single
   leftA = HScroll11.Value
   leftT = HScroll12.Value
   leftJ = HScroll13.Value * pi / 180
   leftL = HScroll14.Value
   rightA = HScroll21.Value
   rightT = HScroll22.Value
   rightJ = HScroll23.Value * pi / 180
   rightL = HScroll24.Value
   s = 3        '步长,此参数影响曲线的光滑程度
   timeCount = timeCount + 1
   For i = 0 To x0 Step s
      y12 = leftA * Sin(2 * pi * (timeCount / leftT + i / leftL) + leftJ)
      y22 = rightA * Sin(2 * pi * (timeCount / rightT - i / rightL) + rightJ)
      y32 = y12 + y22
      If toLeft.Checked And i > 0 Then
         DrawWidth = 2
         Form1.Line (i, y11)-(i + s, y12), RGB(255, 0, 0)
      End If
      y11 = y12
      If toRight.Checked And i > 0 Then
         DrawWidth = 2
         Form1.Line (i, y21)-(i + s, y22), RGB(0, 255, 0)
      End If
      y21 = y22
      If both.Checked And i > 0 Then
         DrawWidth = 3
         Form1.Line (i, y31)-(i + s, y32), RGB(0, 0, 255)
         If boll1 And i <= boll1X And i + s >= boll1X Then
            Picture1.Move boll1X - Picture1.Width / 2, (y31 + y32) / 2 + Picture1.Height / 2
         End If
         If boll2 And i <= boll2X And i + s >= boll2X Then
            Picture2.Move boll2X - Picture2.Width / 2, (y31 + y32) / 2 + Picture2.Height / 2
         End If
      End If
      y31 = y32
   Next i
End Sub

Private Sub about_Click()
   Dim say As String
   say = say + "“驻波的形成”课件" + Chr(13) + Chr(13)
   say = say + "制作:毕广吉" + Chr(13)
   say = say + "天津师范大学物理与电子信息学院" + Chr(13)
   say = say + "2001年7月" + Chr(13)
   say = MsgBox(say, vbOKOnly, "关于“驻波的形成”课件")
End Sub

Private Sub change_Click()
   change.Checked = Not change.Checked
   Frame1.Visible = change.Checked
End Sub

Private Sub exitThis_Click()
   End
End Sub

Private Sub Form_Activate()
   DrawWidth = 1
   Form1.Line (0, 0)-(x0, 0), vbWhite
   'Form1.Line (0, -y0)-(0, y0), vbWhite
End Sub

Private Sub Form_Click()
   If step.Checked Then
      Form1.Cls
      Call Form_Activate
      Call draw
   End If
End Sub

Private Sub Form_DblClick()
   If Not step.Checked Then
      If boll = 0 Then
         boll1X = xx - Picture1.Width / 2
         boll1 = Not boll1
         Picture1.Visible = boll1
      End If
      If boll = 1 Then
         boll2X = xx - Picture2.Width / 2
         boll2 = Not boll2
         Picture2.Visible = boll2
      End If
      boll = 1 - boll
   End If
End Sub

Private Sub Form_Load()
   Timer1.Interval = 50    '此参数影响刷新曲线的时间间隔,单位:毫秒
   Form1.Left = 0
   Form1.Top = 0
   Form1.Width = Screen.Width
   Form1.Height = Screen.Height
   x0 = 800     'Form1.Width
   y0 = 600     'Form1.Height / 2
   Form1.Scale (0, y0)-(x0, -y0)
   HScroll11.Value = y0 / 2
   HScroll12.Value = 150
   HScroll13.Value = 0
   HScroll14.Value = x0 / 2
   HScroll21.Value = y0 / 2
   HScroll22.Value = 150
   HScroll23.Value = 0
   HScroll24.Value = x0 / 2
   Label11.Caption = HScroll11.Value
   Label12.Caption = HScroll12.Value
   Label13.Caption = HScroll13.Value
   Label14.Caption = HScroll14.Value
   Label21.Caption = HScroll21.Value
   Label22.Caption = HScroll22.Value
   Label23.Caption = HScroll23.Value
   Label24.Caption = HScroll24.Value
   HScroll11.Min = y0 / 5          '振幅
   HScroll21.Min = y0 / 5
   HScroll11.Max = y0 * 0.8
   HScroll21.Max = y0 * 0.8
   HScroll12.Min = 5              '周期(毫秒)
   HScroll22.Min = 5
   HScroll12.Max = 100
   HScroll22.Max = 100
   HScroll13.Min = 0               '初位相
   HScroll23.Min = 0
   HScroll13.Max = 360
   HScroll23.Max = 360
   HScroll14.Min = x0 / 4          '波长
   HScroll24.Min = x0 / 4
   HScroll14.Max = x0 * 2
   HScroll24.Max = x0 * 2
   boll1X = 0
   boll2X = 0
   boll1 = False
   boll2 = False
   boll = 0
End Sub

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
   xx = X
   yy = Y
End Sub

Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
   If Button = 2 Then
      Form1.PopupMenu showMnu
   End If
End Sub

Private Sub Frame1_Click()
   change.Checked = Not change.Checked
   Frame1.Visible = change.Checked
End Sub

Private Sub HScroll11_Change()
   Label11.Caption = HScroll11.Value
End Sub

Private Sub HScroll11_Scroll()
   Label11.Caption = HScroll11.Value
End Sub

Private Sub HScroll12_Change()
   Label12.Caption = HScroll12.Value
End Sub

Private Sub HScroll12_Scroll()
   Label12.Caption = HScroll12.Value
End Sub

Private Sub HScroll13_Change()
   Label13.Caption = HScroll13.Value
End Sub

Private Sub HScroll13_Scroll()
   Label13.Caption = HScroll13.Value
End Sub

Private Sub HScroll14_Change()
   Label14.Caption = HScroll14.Value
End Sub

Private Sub HScroll14_Scroll()
   Label14.Caption = HScroll14.Value
End Sub

Private Sub HScroll21_Change()
   Label21.Caption = HScroll21.Value
End Sub

Private Sub HScroll22_Change()
   Label22.Caption = HScroll22.Value
End Sub

Private Sub HScroll22_Scroll()
   Label22.Caption = HScroll22.Value
End Sub

Private Sub HScroll23_Change()
   Label23.Caption = HScroll23.Value
End Sub

Private Sub HScroll23_Scroll()
   Label23.Caption = HScroll23.Value
End Sub

Private Sub HScroll24_Change()
   Label24.Caption = HScroll24.Value
End Sub

Private Sub HScroll24_Scroll()
   Label24.Caption = HScroll24.Value
End Sub

Private Sub pause_Click()
   pause.Checked = Not pause.Checked
   Timer1.Enabled = Not Timer1.Enabled
   step.Enabled = Not pause.Checked
End Sub

Private Sub readMe_Click()
   Dim say As String
   say = say + "1.从快捷菜单中选择欲显示的曲线。" + Chr(13)
   say = say + "2.双击窗体加入或除去质点:" + Chr(13)
   say = say + "  第一次双击加入第一个质点," + Chr(13)
   say = say + "  第二次双击加入第二个质点," + Chr(13)
   say = say + "  第三次双击除去第一个质点," + Chr(13)
   say = say + "  第四次双击除去第二个质点," + Chr(13)
   say = say + "  其余类推。" + Chr(13)
   say = say + "3.选择“单步”以后,每一次单击前进一步。" + Chr(13)
   say = say + "4.选择“暂停”后若要继续,应再一次" + Chr(13)
   say = say + "  选择“暂停”去掉对钩。" + Chr(13)
   say = say + "5.通过选择“显示修改参数对话框”" + Chr(13)
   say = say + "  可以修改系统参数。" + Chr(13)
   say = MsgBox(say, vbOKOnly, "“驻波的形成”课件使用说明:")
End Sub

Private Sub step_Click()
   step.Checked = Not step.Checked
   Timer1.Enabled = Not Timer1.Enabled
   pause.Enabled = Not step.Checked
End Sub

Private Sub Timer1_Timer()
   Form1.Cls
   Call Form_Activate
   Call draw
End Sub

Private Sub toLeft_Click()
   toLeft.Checked = Not toLeft.Checked
   le = toLeft.Checked
End Sub

Private Sub toRight_Click()
   toRight.Checked = Not toRight.Checked
   ri = toRight.Checked
End Sub

Private Sub both_Click()
   both.Checked = Not both.Checked
   su = both.Checked
   Picture1.Visible = su
   Picture2.Visible = su
End Sub

⌨️ 快捷键说明

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