Re: Making a class module..
Try with the following changes:
VB Code:
Option Explicit
Dim z As Long
Dim r As Byte, g As Byte, b As Byte, flag As Byte, d(3) As Byte
Public Sub BlendForm(ByRef iobject As Form)
Dim iTimes As Long
r = 255: g = 255: b = 255: flag = 0
For z = 0 To iTimes
iobject.BackColor = Disco
Next
End Sub
Private Function Disco() As Long
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
Disco = RGB(r, g, b)
End Function
Private 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 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
VB Code:
Option Explicit
Dim ifrm As frmEffects
Private Sub Form_Load()
Set ifrm = New frmEffects
ifrm.BlendForm Form1
End Sub
Re: Making a class module..
Don't put Form1 in brackets in the function call, otherwise it is treated as an expression evaluation and passed ByVal where instead you want ByRef.
Also, maybe you should make a property to hold the form reference, set that first, and then there is no need to pass a reference to each of the effect functions.
Re: Making a class module..
Quote:
Originally Posted by |2eM!x
But its returning crazy errors..
Anything specific or just "something crazy has happened"? ;)
Re: Making a class module..
Quote:
Originally Posted by |2eM!x
But its returning crazy errors..i hope someone will help me here. Thanks :wave:
What are the specifics on the "crazy errors"?