查看: 349  |  回复: 0
  VB6 随机文字大小、颜色和立体图像
楼主
发表于 2023年4月21日 13:36

新建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


您需要登录后才可以回帖 登录 | 立即注册
【本版规则】请勿发表违反国家法律的内容,否则会被冻结账号和删贴。
用户名: 立即注册
密码:
2020-2024 MaNongKu.com