📄 form1.frm
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 9210
ClientLeft = 60
ClientTop = 450
ClientWidth = 6960
LinkTopic = "Form1"
ScaleHeight = 9210
ScaleWidth = 6960
StartUpPosition = 2 '屏幕中心
Begin VB.CommandButton Command4
Caption = "起始角度"
Height = 375
Left = 3600
TabIndex = 5
Top = 240
Width = 1215
End
Begin VB.CommandButton Command3
Caption = "提示/帮助"
Height = 375
Left = 5160
TabIndex = 4
Top = 240
Width = 1215
End
Begin VB.CommandButton Command2
Caption = "设定摆长"
Height = 375
Left = 2040
TabIndex = 3
Top = 240
Width = 1215
End
Begin VB.CommandButton Command1
Caption = "开始"
Height = 375
Left = 360
TabIndex = 1
Top = 240
Width = 1215
End
Begin VB.OptionButton Option1
Caption = "顶点"
Height = 255
Left = 2760
TabIndex = 0
Top = 1200
Width = 855
End
Begin VB.Timer Timer1
Enabled = 0 'False
Interval = 20
Left = 6240
Top = 1800
End
Begin VB.Label Label1
Caption = "Label1"
Height = 255
Left = 3720
TabIndex = 2
Top = 1200
Width = 2175
End
Begin VB.Shape Shape1
Height = 375
Left = 2655
Shape = 3 'Circle
Top = 3480
Width = 375
End
Begin VB.Line Line1
X1 = 2835
X2 = 2835
Y1 = 1425
Y2 = 3480
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim l As Integer
Dim i As Integer
Dim k As Boolean
Private Sub Command1_Click()
If Command1.Caption = "开始" Then
Command1.Caption = "暂停"
Timer1.Enabled = True
Else
Command1.Caption = "开始"
Timer1.Enabled = False
End If
End Sub
Private Sub Command2_Click()
Dim m
m = InputBox("请你输入你需要的摆长,主意摆长不要过大!", "数据输入")
If m = "" Then
MsgBox "警告,你没有输入数据,程序将按照设定摆长执行!", vbOKOnly, "警告"
Else
Label1.Caption = "摆绳长度为:" & m
l = m
Line1.X2 = Line1.X1
Line1.Y2 = Line1.Y1 + m
Shape1.Left = Line1.X2 - 187.5
Shape1.Top = Line1.Y2
End If
End Sub
Private Sub Command3_Click()
MsgBox " 由于电脑中像素和事迹的长度需要一定的转换,所以这里只是进行了一定的模拟,无法反映真实的情况,如果有需要请在物理实验室进行此类试验。", vbOKOnly, "提示/警告"
End Sub
Private Sub Command4_Click()
Dim n
n = InputBox("属于摆绳的起始角度,再-20-+20之间", "数据输入(正数为右,负数之为左)")
If n = "" Then
MsgBox "警告,你没有输入数据,程序将按照设定角度执行!", vbOKOnly, "警告"
Else
i = n
Line1.X2 = Line1.X1 - Sin(i * 3.1415926 / 180) * l
Line1.Y2 = Line1.Y1 + Cos(i * 3.1415926 / 180) * l
Shape1.Left = Line1.X2 - 187.5
Shape1.Top = Line1.Y2
End If
End Sub
Private Sub Form_Load()
k = True
Label1.Caption = ""
l = Sqr((Line1.X2 - Line1.X1) * (Line1.X2 - Line1.X1) + (Line1.Y2 - Line1.Y1) * (Line1.Y2 - Line1.Y1))
Label1.Caption = "摆绳长度为:" & l
End Sub
Private Sub Timer1_Timer()
Dim X2 As Integer
Dim Y2 As Integer
If k = True Then
Line1.X2 = Line1.X1 - Sin(i * 3.1415926 / 180) * l
Line1.Y2 = Line1.Y1 + Cos(i * 3.1415926 / 180) * l
i = i - 1
If i < -30 Then
k = False
End If
ElseIf k = False Then
Line1.X2 = Line1.X1 - Sin(i * 3.1415926 / 180) * l
Line1.Y2 = Line1.Y1 + Cos(i * 3.1415926 / 180) * l
i = i + 1
If i > 30 Then
k = True
End If
End If
Shape1.Left = Line1.X2 - 187.5
Shape1.Top = Line1.Y2
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -