|
-
Sep 28th, 2002, 11:01 AM
#1
Thread Starter
Addicted Member
system variables
Hi all
How to add events to basic variables. For EX ..When the value of Interger changes it should fire an event and if the valus is 0 another event .. like that ...
-
Sep 28th, 2002, 11:04 AM
#2
PowerPoster
use the raise Event method of VB
-
Sep 28th, 2002, 11:05 AM
#3
PowerPoster
Well
VB Code:
Select Case INTVARIABLE
Case 0
' Do something
Case 1
' Do something
End Select
Remaining quiet down here !!!
BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....
-
Sep 28th, 2002, 11:08 AM
#4
Thread Starter
Addicted Member
In elobrate
Make it more clear plz .May be a sample code or snippet
-
Sep 28th, 2002, 11:10 AM
#5
PowerPoster
Well
How is this variable being changed? I mean there is only so many ways it can be changed, right? What data is it holding?
Remaining quiet down here !!!
BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....
-
Sep 28th, 2002, 11:16 AM
#6
Thread Starter
Addicted Member
Need help
I use a global variable
public withevents intEmp as integer
i use to hold count
when its value get changed by anywhere in the project a particular event shoul fire and if it is 0 another event should fire
private sub intEmp_VChange(Val as integer) ' if value cahges
end sub
private sub intEmp_Vzero ' if it is zero
end sub
Last edited by vijayanand; Sep 28th, 2002 at 11:23 AM.
Variety is the spice of life
-
Sep 28th, 2002, 11:23 AM
#7
Member
VB Code:
Option Explicit
Public Event TestA(j As Integer)
Public Event TestB(i As Integer)
Private Sub Form_Load()
Dim x As Integer
Randomize
x = (Rnd * 1) '* 100
MsgBox x
If x = 1 Then
RaiseEvent TestA(x)
Else
RaiseEvent TestA(x)
End If
End Sub
-
Sep 28th, 2002, 11:27 AM
#8
Thread Starter
Addicted Member
How to capture that event
how to cature that event raised by
Variety is the spice of life
-
Sep 28th, 2002, 11:33 AM
#9
Need-a-life Member
Try this....
VB Code:
Option Explicit
Private MYintEmp As Integer
Public Event VChanged()
Public Event VZero()
Public Property Get intEmp() As Integer
intEmp = MYintEmp
End Property
Public Property Let intEmp(ByVal iNewValue As Integer)
MYintEmp = iNewValue
If MYintEmp = 0 Then
RaiseEvent VZero
Else
RaiseEvent VChanged
End If
End Property
Private Sub Command1_Click()
Randomize Timer
'Int((upperbound - lowerbound + 1) * Rnd + lowerbound)
intEmp = (101 * Rnd)
End Sub
But... this should be a Class Module, so that you can create an object (withevents) to get its events.
Emiliano F. Martín
If a post has helped you then please Rate it! (and give the user points he/she deserves by clicking on the image).
Encourage the person who helped you to keep doing it, and give him the points he deserves.
MP3 Organizer: Freeware to logically organize all your MP3s.
-
Sep 28th, 2002, 12:11 PM
#10
Thread Starter
Addicted Member
Need clarification
I pasted the code in a module it gives error in
Public Event VChanged()
Public Event VZero()
RaiseEvent VZero
RaiseEvent VChanged
syntax error
Variety is the spice of life
-
Sep 28th, 2002, 12:15 PM
#11
Not NoteMe
Re: Need clarification
Originally posted by vijayanand
I pasted the code in a module it gives error in
Public Event VChanged()
Public Event VZero()
RaiseEvent VZero
RaiseEvent VChanged
syntax error
Did you put it in a CLASS module.
Add a class module the same way as a module, project->add->Class Module.
Don't use the class module wizard.
Quotes:
"I am getting better then you guys.." NoteMe, on his leet english skills.
"And I am going to meat her again later on tonight." NoteMe
"I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
"my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
Have I helped you? Please Rate my posts. 
-
Sep 28th, 2002, 12:29 PM
#12
Thread Starter
Addicted Member
help
I pasted the code in a module it gives error in
Public Event VChanged()
Public Event VZero()
RaiseEvent VZero
RaiseEvent VChanged
syntax error
Variety is the spice of life
-
Sep 28th, 2002, 12:35 PM
#13
Thread Starter
Addicted Member
Variety is the spice of life
-
Sep 28th, 2002, 12:37 PM
#14
Need-a-life Member
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
|