Private Sub Timer2_Timer()
Dim se1 As Integer
Dim se2 As Integer
Dim se3 As IntegerWhile (se1 > 0)pic1.BackColor = RGB(se1, se2, se3)se1 = se1 + 100
se2 = se2 + 200
se3 = se3 + 300
WendEnd Sub这段代码背景颜色就一一直是同一个颜色 ,怎么自动改变呢,不许用随即函数啊
Dim se1 As Integer
Dim se2 As Integer
Dim se3 As IntegerWhile (se1 > 0)pic1.BackColor = RGB(se1, se2, se3)se1 = se1 + 100
se2 = se2 + 200
se3 = se3 + 300
WendEnd Sub这段代码背景颜色就一一直是同一个颜色 ,怎么自动改变呢,不许用随即函数啊
Timer1.Interval = 500
End SubPrivate Sub Timer1_Timer()
Static i As Integer
Pic1.BackColor = QBColor(i)
i = i + 1
If i > 15 Then i = 0
End Sub
Timer1.Interval = 500
Timer2.Interval = 500
End SubPrivate Sub Timer1_Timer()
Static i As Integer
Pic1.BackColor = QBColor(i)
i = i + 1
If i > 15 Then i = 0
End SubPrivate Sub Timer2_Timer()
Dim i As Byte, j As Byte, k As Byte
Timer2.Enabled = False
For i = 0 To 254
For j = 0 To 254
For k = 0 To 254
Pic2.BackColor = RGB(i, j, k)
ys 0.01
Next k
Next j
Next i
Timer2.Enabled = True
End SubPrivate Sub ys(t As Single)
Dim tt As Single
tt = Timer
Do
DoEvents
Loop While Timer - tt < t
End Sub
Dim i As Long, r As Long, g As Long, b As Longi = Picture1.BackColorb = ((i Mod 256) + 4) Mod 256
If b < 0 Then b = b + 256i = i \ 256
g = ((i Mod 256) + 2) Mod 256
If g < 0 Then g = g + 256i = i \ 256
r = ((i Mod 256) + 1) Mod 256
If r < 0 Then r = r + 256Picture1.BackColor = RGB(r, g, b)End Sub
柔和一点不闪烁的:
Static ri As Integer, gi As Integer, bi As Integer
Static notfirstflag As Boolean
If Not notfirstflag Then
ri = 1: gi = 1: bi = 1: notfirstflag = True
End If
r = r + ri * 2
If r >= 200 Then
r = 200: ri = -ri
ElseIf r < 50 Then
r = 50: ri = -ri
End Ifg = g + gi * 4If g >= 200 Then
g = 200: gi = -gi
ElseIf g < 50 Then
g = 50: gi = -gi
End Ifb = b + bi * 6
If b >= 200 Then
b = 200: bi = -bi
ElseIf b < 50 Then
b = 50: bi = -bi
End IfPicture1.BackColor = RGB(r Mod 256, g Mod 256, b Mod 256)End Sub
Dim se1 As Integer
Dim se2 As Integer
Dim se3 As Integer While (se1 > 0)
pic1.BackColor = RGB(se1, se2, se3)
se1 = (se1 + 100 ) mod 256
se2 = (se2 + 200) mod 256
se3 = (se3 + 300)mod 256
Wend End Sub
Dim se2 As Integer
Dim se3 As Integer
Private Sub Timer2_Timer()
pic1.BackColor = RGB(se1, se2, se3)
se1 = (se1 + 100 ) mod 256
se2 = (se2 + 200) mod 256
se3 = (se3 + 300)mod 256
End Sub
这个代码不错 颜色可以变 但是你的第二个帖子的代码怎么用了两个 timer控件
Private Sub Form_Load()
Timer1.Interval = 500
End SubPrivate Sub Timer1_Timer()
Dim red As Byte, green As Byte, k As Byte, blue As Byte
Static L As Integer
Select Case L '-------在这定义六种颜色
Case 0 '黑
red = 0
green = 0
blue = 0
Case 1 '白
red = 255
green = 255
blue = 255
Case 2 '黄
red = 255
green = 255
blue = 0
Case 3 '红
red = 255
green = 0
blue = 0
Case 4 '绿
red = 0
green = 255
blue = 0
Case 5 '蓝
red = 0
green = 0
blue = 255
Case 6 '品红
red = 255
green = 0
blue = 255
End Select
L = IIf(L < 6, L + 1, 0) '在这决定循环
Pic1.BackColor = RGB(red, green, blue)
End Sub
郁闷,少拷贝了两行Private Sub Timer1_Timer()
Static r As Integer, g As Integer, b As Integer
Static ri As Integer, gi As Integer, bi As Integer
Static notfirstflag As Boolean
If Not notfirstflag Then
ri = 1: gi = 1: bi = 1: notfirstflag = True
End If
r = r + ri * 2
If r >= 200 Then
r = 200: ri = -ri
ElseIf r < 50 Then
r = 50: ri = -ri
End Ifg = g + gi * 4If g >= 200 Then
g = 200: gi = -gi
ElseIf g < 50 Then
g = 50: gi = -gi
End Ifb = b + bi * 6
If b >= 200 Then
b = 200: bi = -bi
ElseIf b < 50 Then
b = 50: bi = -bi
End IfPicture1.BackColor = RGB(r Mod 256, g Mod 256, b Mod 256)End Sub
不会的,你有没有给Timer2设置Interval属性?如果是0,当然不会变了。
Dim se2 As Integer
Dim se3 As IntegerPrivate Sub Form_Load()
Timer1.Enabled = True
Timer1.Interval = 1000
End SubPrivate Sub Timer1_Timer()
pic1.BackColor = RGB(se1, se2, se3)
se1 = (se1 + 100) Mod 256
se2 = (se2 + 200) Mod 256
se3 = (se3 + 300) Mod 256
End Sub