下面是斑竹的杰作,问一下可不可以把ELSEIF 改为 IF 然后再在每个 IF ....................... 后加上 END IF ,图片是要达到的效果.诚心领教
此主题相关图片如下:
Option Explicit
Dim R As Integer, G As Integer, B As Integer
Dim Step As Integer
Private Sub Command1_Click()
Timer1.Interval = 10
Timer1.Enabled = True
End Sub
Private Sub Form_Load()
Line1.X2 = Line1.X1
Timer1.Enabled = False
Command1.Caption = "Start"
End Sub
Private Sub Timer1_Timer()
If Step = 0 Then
Line1.BorderColor = vbRed
Line1.X2 = Line1.X1 + 3000 * (R / 255)
R = R + 1
G = 0
B = 0
If R = 255 Then
Step = 1
End If
ElseIf Step = 1 Then
Line1.BorderColor = vbGreen
Line1.X2 = Line1.X1 + 3000 * (G / 255)
R = 0
G = G + 1
B = 0
If G = 255 Then
Step = 2
End If
ElseIf Step = 2 Then
Line1.BorderColor = vbBlue
Line1.X2 = Line1.X1 + 3000 * (B / 255)
R = 0
G = 0
B = B + 1
If B = 255 Then
Step = 0
End If
End If
Label1.BackColor = RGB(R, G, B)
End Sub