新建From1(窗体),新建Command1(按钮CommandButton),Picture1(PictureBox)代码:
Private Sub Form_Load()
Command1.Caption = "随机文字"
Command2.Caption = "立体图形"
Form1.ScaleMode = 1
Picture1.ScaleMode = 1
End Sub
'随机文字动画
Private Sub Command1_Click()
Picture1.Cls
Do
nn = Int(45 * Rnd)
If nn > 0 Then
Picture1.FontSize = nn
End If
Picture1.CurrentX = Rnd * Picture1.ScaleWidth - 1000
Picture1.CurrentY = Rnd * Picture1.ScaleHeight
Picture1.ForeColor = RGB(Rnd * 256, Rnd * 256, Rnd * 256)
Picture1.Print "码农库"
n = n + 1
If n > 50 Then
n = 0
Picture1.BackColor = QBColor(Rnd * 15)
End If
DoEvents
Loop
End Sub
'立体随机动画
Private Sub Command2_Click()
Dim m, n
Picture1.DrawWidth = 1
Picture1.BackColor = RGB(210, 150, 0)
Picture1.Cls
Do
m = Rnd * Picture1.ScaleWidth
n = Rnd * Picture1.ScaleHeight - 500
For i = 0 To Rnd * 800
Picture1.Line (m, n + 2.5 * i)-(m + i / 2, n + 2 * i), RGB(180, 180, 180)
Picture1.Line (m, n + 2.5 * i)-(m - i / 2, n + 2 * i), RGB(80, 80, 80)
Next i
DoEvents
Loop
End Sub