用VB程序怎么做一个心型图?
1个回答
展开全部
Dim X1, Y1, X2, Y2 As Integer
Dim I As Integer
Dim J As Boolean
Dim K As IntegerDim WithEvents Label1 As Label
Dim WithEvents Timer1 As TimerPrivate Sub Form_Activate()
I = 100
K = 100
X1 = Me.Width / 2
Y1 = Me.Height / 3
X2 = X1
Y2 = Y1
Label1.Top = Me.Height / 2 - Label1.Height / 2
Label1.Left = Me.Width / 2 - Label1.Width / 2
End SubPrivate Sub Form_Load() Me.BackColor = &H0&
Me.FillColor = RGB(Rnd * 255, Rnd * 255, Rnd * 255)
Me.ForeColor = RGB(Rnd * 255, Rnd * 255, Rnd * 255)
Me.DrawMode = 13
Me.DrawWidth = 2
Me.FillStyle = 7
Set Label1 = Me.Controls.Add("VB.Label", "Label1")
Set Timer1 = Me.Controls.Add("VB.Timer", "Timer1")
Label1.Visible = True
Label1.AutoSize = True
Label1.BackStyle = 0
Label1.Caption = "I LOVE YOU"
Label1.Font.Size = 60
Label1.ForeColor = &HFF00&
Timer1.Enabled = True
Timer1.Interval = 10
Me.WindowState = 2
End SubPrivate Sub Timer1_Timer()
Me.Circle (X1, Y1), 250
Me.Circle (X2, Y2), 250
If Y1 <= Me.Height - 1200 Then
X1 = X1 + K
Y1 = Y1 - I
X2 = X2 - K
Y2 = Y2 - I
I = I - 2
If Y1 <= Me.Height / 3 Then
K = K - 1
ElseIf Y1 >= Me.Height / 3 Then
K = K - 5
End If
Else
I = 100
K = 100
X1 = Me.Width / 2
Y1 = Me.Height / 3
X2 = X1
Y2 = Y1
Me.FillColor = RGB(Rnd * 255, Rnd * 255, Rnd * 255)
Me.ForeColor = RGB(Rnd * 255, Rnd * 255, Rnd * 255) End If
Me.DrawWidth = 3
Me.PSet (Rnd * Me.Width, Rnd * Me.Height), RGB(Rnd * 225, Rnd * 225, Rnd * 225)
Me.DrawWidth = 2
End SubPrivate Sub Form_Click()
End
End SubPrivate Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
End
End Sub
Dim I As Integer
Dim J As Boolean
Dim K As IntegerDim WithEvents Label1 As Label
Dim WithEvents Timer1 As TimerPrivate Sub Form_Activate()
I = 100
K = 100
X1 = Me.Width / 2
Y1 = Me.Height / 3
X2 = X1
Y2 = Y1
Label1.Top = Me.Height / 2 - Label1.Height / 2
Label1.Left = Me.Width / 2 - Label1.Width / 2
End SubPrivate Sub Form_Load() Me.BackColor = &H0&
Me.FillColor = RGB(Rnd * 255, Rnd * 255, Rnd * 255)
Me.ForeColor = RGB(Rnd * 255, Rnd * 255, Rnd * 255)
Me.DrawMode = 13
Me.DrawWidth = 2
Me.FillStyle = 7
Set Label1 = Me.Controls.Add("VB.Label", "Label1")
Set Timer1 = Me.Controls.Add("VB.Timer", "Timer1")
Label1.Visible = True
Label1.AutoSize = True
Label1.BackStyle = 0
Label1.Caption = "I LOVE YOU"
Label1.Font.Size = 60
Label1.ForeColor = &HFF00&
Timer1.Enabled = True
Timer1.Interval = 10
Me.WindowState = 2
End SubPrivate Sub Timer1_Timer()
Me.Circle (X1, Y1), 250
Me.Circle (X2, Y2), 250
If Y1 <= Me.Height - 1200 Then
X1 = X1 + K
Y1 = Y1 - I
X2 = X2 - K
Y2 = Y2 - I
I = I - 2
If Y1 <= Me.Height / 3 Then
K = K - 1
ElseIf Y1 >= Me.Height / 3 Then
K = K - 5
End If
Else
I = 100
K = 100
X1 = Me.Width / 2
Y1 = Me.Height / 3
X2 = X1
Y2 = Y1
Me.FillColor = RGB(Rnd * 255, Rnd * 255, Rnd * 255)
Me.ForeColor = RGB(Rnd * 255, Rnd * 255, Rnd * 255) End If
Me.DrawWidth = 3
Me.PSet (Rnd * Me.Width, Rnd * Me.Height), RGB(Rnd * 225, Rnd * 225, Rnd * 225)
Me.DrawWidth = 2
End SubPrivate Sub Form_Click()
End
End SubPrivate Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
End
End Sub
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询