|
-
Sep 5th, 2005, 08:52 PM
#1
Thread Starter
Admodistrator
Making a class module..
I want to make a class module for adding effects to my form.
So far i have added the following to a class module:
VB Code:
Option Explicit
Public Sub BlendForm(ByRef iobject As Form)
Dim z As Long
Dim r As Byte, g As Byte, b As Byte, flag As Byte, d(3) As Byte
r = 255: g = 255: b = 255: flag = 0
For z = 0 To iTimes
iobject.BackColor = Disco
Loop
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
and in my form i wrote
VB Code:
Option Explicit
Dim ifrm As FrmEffects
Private Sub Form_Load()
Set ifrm = New FrmEffects
ifrm.BlendForm (Form1)
End Sub
But its returning crazy errors..i hope someone will help me here. Thanks
-
Sep 5th, 2005, 10:26 PM
#2
Hyperactive Member
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
Sometimes what you're looking for is exactly where you left it.
-
Sep 6th, 2005, 12:02 AM
#3
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.
-
Sep 6th, 2005, 12:13 AM
#4
Frenzied Member
Re: Making a class module..
 Originally Posted by |2eM!x
But its returning crazy errors..
Anything specific or just "something crazy has happened"?
-
Sep 6th, 2005, 11:40 AM
#5
Re: Making a class module..
 Originally Posted by |2eM!x
But its returning crazy errors..i hope someone will help me here. Thanks 
What are the specifics on the "crazy errors"?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|