永发信息网

VB高手请进,高分

答案:2  悬赏:50  手机版
解决时间 2021-07-26 11:23
  • 提问者网友:星軌
  • 2021-07-25 22:22
这个类似烟花的代码怎么写!要用VB写详细代码,谢谢
最佳答案
  • 五星知识达人网友:拾荒鲤
  • 2021-07-25 23:38

添加一个Timer


加入以下代码


Private Sub Form_Load()
Me.ScaleMode = 3
Me.AutoRedraw = True
Timer1.Interval = 100
End Sub


Static Sub Paint()


Const PI = 3.14169265
Dim X As Single
Dim Y As Single
Dim R As Single

Dim x1 As Single
Dim y1 As Single

Randomize

If R < 100 Then R = R + 2 Else Timer1.Enabled = False
If X = 0 Then X = Rnd * Me.ScaleWidth: Y = Rnd * Me.ScaleHeight

For I = 0 To 359
x1 = R * Cos(I / PI) + X
y1 = R * Sin(I / PI) + Y
PSet (x1, y1), RGB(Rnd * 255, Rnd * 255, Rnd * 255)
Next I


End Sub


Private Sub Timer1_Timer()
Paint
End Sub

全部回答
  • 1楼网友:梦中风几里
  • 2021-07-26 01:07

加个timer控件,在里面写:

Private Sub Timer1_Timer() Dim M As String Dim X0, Y0, I As Integer ScaleMode = 0 FontSize = 24 Me.ForeColor = QBColor(Rnd * 15) M = "新年快乐!" Cls CurrentX = Form1.Width / 2 - TextWidth(M) / 2 CurrentY = Form1.Height / 2 - TextHeight(M) Print M For I = 1 To 100 DrawWidth = (DrawWidth + 1) Mod 10 + 1 X0 = ScaleHeight * 2 * Rnd Y0 = ScaleWidth * 2 * Rnd ' PSet (X0, Y0), QBColor(Rnd * 15) PSet (X0, Y0), RGB(Rnd * 255, Rnd * 255, Rnd * 255) Next I End Sub 一个雪花飘落的感觉。

我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯