📄 starfield.frm
字号:
VERSION 5.00
Begin VB.Form Form1
BackColor = &H00000000&
Caption = "Form1"
ClientHeight = 5460
ClientLeft = 60
ClientTop = 345
ClientWidth = 7110
FillColor = &H0000FFFF&
ForeColor = &H00FFFF80&
LinkTopic = "Form1"
ScaleHeight = 5460
ScaleWidth = 7110
StartUpPosition = 3 'Windows Default
Begin VB.CommandButton cmdQuit
Caption = "Command1"
Height = 375
Left = 6000
TabIndex = 0
Top = 4920
Width = 975
End
Begin VB.Timer Timer1
Interval = 1
Left = 360
Top = 4560
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'模拟一场流星雨的例子,从中看看随机数的使用方法
Dim X(100), Y(100), pace(100), size(100) As Integer
Private Sub cmdQuit_Click()
'Unload Me is actually a better way to end your
'program than End, since End may leave parts of
'the program in memory.
Unload Me
End Sub
Private Sub Form_Activate()
Randomize
'Randomize is a statement that along with Rnd allows
'you to generate Random numbers. Randomize initializes
'this random number generator based on a value from your
'system timer.
For I = 1 To 100
'The Int function returns the integer portion of the
'number passed to it. For example X1 = Int(99.8) will
'return a value of 99 to X1, so will Int(99.1).
X1 = Int(Form1.Width * Rnd)
Y1 = Int(Form1.Height * Rnd)
'The idea of this pace is to generate a random speed
'as it goes through the loop. Since it goes through the
'loop so fast you may not notice the changes. If you want
'to experiment with this then comment out the pace1 = Int..
'line and uncomment the pace1 = 0. Try changing the value
'of zero and watch the speed change. You may prefer creating
'a variable called velocity and then set pace1=velocity, this
'way you could control the speed by setting new value for
'velocity.
pace1 = Int(500 - (Int(Rnd * 499)))
'pace1 = 0
'This next piece assigns a random value to size which is
'passed to the Circle method in the Timer1_Timer event
'resulting in different size circles. You can increase
'the max size of the by changing the 25 but the circles
'will not be filled. You'll have to do some fiddling on
'your own to fill the circles without drawing tracks on
'background.
size1 = 25 * Rnd
X(I) = X1
Y(I) = Y1
pace(I) = pace1
size(I) = size1
Next
End Sub
Private Sub Timer1_Timer()
For I = 1 To 100
Circle (X(I), Y(I)), size(I), BackColor
Y(I) = Y(I) + pace(I)
If Y(I) >= Form1.Height Then Y(I) = 0: X(I) = Int(Form1.Width * Rnd)
Circle (X(I), Y(I)), size(I)
Next
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -