vb编程,新手求助

2024-11-28 14:33:45
推荐回答(1个)
回答1:

完整程序:
Option Explicit
'公共部分:
Const x1 As Integer = 0
Const x2 As Integer = 2000
Const y1 As Integer = 0
Const y2 As Integer = 2000 '设置划线的坐标
Dim Co As Integer ' 相当于for。但是可以控制渐变速度

Private Sub Form_Load()
Timer1.Enabled = True
Timer1.Interval = 20
End Sub

Private Sub Timer1_Timer()
'在timer的timer事件里头:
Co = Co + 1
If Co >= 255 Then
Co = 0
End If
Form1.Cls
Form1.Line (x1, y1)-(x2, y2), RGB(Co, 0, 0)
Print Co
End Sub

窗体上只要一个timer就行了
本人测试通过