VB Code:
Option Explicit Dim r As Byte, g As Byte, b As Byte, d(3) As Byte, flag As Byte Private Sub Form_Load() Randomize r = 255: g = 255: b = 255: flag = 0 End Sub Function Ran(ByVal a As Byte, ByVal c As Byte) If ((Rnd > 0.667 Or c = 0) And c < 255) Then c = c + 1 d(a) = 2 ElseIf ((Rnd <= 0.5 Or c = 255) And c > 0) Then c = c - 1 d(a) = 1 Else d(a) = 0 End If Ran = c End Function Function DoIt(ByVal a As Byte, ByVal c As Byte) If ((d(a) = 2 And c < 255) Or c = 0) Then c = c + 1 d(a) = 2 Else If ((d(a) = 1 And c) Or c = 255) Then c = c - 1 d(a) = 1 End If If a = 3 Then If (d(1) + d(2) + d(3) = 0) Then flag = 1 End If End If DoIt = c End Function Function Disco() If flag Then r = DoIt(1, r) g = DoIt(2, g) b = DoIt(3, b) flag = flag - 1 Else r = Ran(1, r) g = Ran(2, g) b = Ran(3, b) flag = 50 End If Me.BackColor = RGB(r, g, b) End Function Private Sub Timer1_Timer() Disco End Sub
NOTE: This was converted from HTML, i think the link to its HTML source was www.wsabstract.com





Reply With Quote