Page 1 / 1
Reference VB6 Codes
10/08/2011 11:13 am

Administrator
Junior Member


Regist.: 10/07/2011
Topics: 3
Posts: 7
OFFLINE
Changing color of your background(smooth) no flickering parang disco ang style!

Option Explicit
Dim r As Byte, g As Byte, b As Byte, flag As Byte, d(3) As Byte

Private Sub Form_Load()
    r = 255: g = 255: b = 255: flag = 0
End Sub

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

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

Private Sub Timer1_Timer()
Disco
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



................







Quote   
10/08/2011 11:36 am

Senior Member


Regist.: 10/07/2011
Topics: 9
Posts: 11
OFFLINE
sir ung sa traffic lights panu yun?
................
Kelvs
Quote   
10/09/2011 12:40 am

Administrator
Junior Member


Regist.: 10/07/2011
Topics: 3
Posts: 7
OFFLINE
You need Timer, 3 images (Green,Orange,Red)

Timer set to 1000 (1 second)

Double click timer

Private Sub Timer1

if imgGreen.visible = true then
   imgGreen.visible = false
   imgOrange.visible = true
   imgRed.visible = false

elseif imgOrange = true then
   imgGreen.visible = false
   imgOrange.visible = false
   imgRed.visible = true

elseif imgRed = true then
   imgGreen.visible=true
   imgOrange.visible=false
   imgRed.visible=false

endif


................







Quote   
Page 1 / 1
Login with Facebook to post
Preview