Results 1 to 14 of 14

Thread: system variables

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2002
    Location
    India
    Posts
    151

    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 ...

  2. #2
    PowerPoster
    Join Date
    Aug 2000
    Location
    India
    Posts
    2,288
    use the raise Event method of VB

  3. #3
    PowerPoster
    Join Date
    Aug 2000
    Location
    IN SILENCE
    Posts
    6,441

    Well

    VB Code:
    1. Select Case INTVARIABLE
    2.  
    3. Case 0
    4.  
    5. ' Do something
    6.  
    7. Case 1
    8.  
    9. ' Do something
    10.  
    11. End Select
    Remaining quiet down here !!!

    BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Sep 2002
    Location
    India
    Posts
    151

    In elobrate

    Make it more clear plz .May be a sample code or snippet

  5. #5
    PowerPoster
    Join Date
    Aug 2000
    Location
    IN SILENCE
    Posts
    6,441

    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....

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Sep 2002
    Location
    India
    Posts
    151

    Question 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

  7. #7
    Member
    Join Date
    Apr 2002
    Location
    QLD, AUS
    Posts
    50
    VB Code:
    1. Option Explicit
    2.  
    3. Public Event TestA(j As Integer)
    4. Public Event TestB(i As Integer)
    5.  
    6. Private Sub Form_Load()
    7.     Dim x As Integer
    8.     Randomize
    9.     x = (Rnd * 1) '* 100
    10.     MsgBox x
    11.     If x = 1 Then
    12.         RaiseEvent TestA(x)
    13.     Else
    14.         RaiseEvent TestA(x)
    15.     End If
    16. End Sub

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Sep 2002
    Location
    India
    Posts
    151

    How to capture that event

    how to cature that event raised by
    Variety is the spice of life

  9. #9
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    Try this....

    VB Code:
    1. Option Explicit
    2.  
    3. Private MYintEmp As Integer
    4.  
    5. Public Event VChanged()
    6. Public Event VZero()
    7.  
    8. Public Property Get intEmp() As Integer
    9.     intEmp = MYintEmp
    10. End Property
    11.  
    12. Public Property Let intEmp(ByVal iNewValue As Integer)
    13.     MYintEmp = iNewValue
    14.    
    15.     If MYintEmp = 0 Then
    16.         RaiseEvent VZero
    17.     Else
    18.         RaiseEvent VChanged
    19.     End If
    20. End Property
    21.  
    22. Private Sub Command1_Click()
    23.     Randomize Timer
    24.    
    25.     'Int((upperbound - lowerbound + 1) * Rnd + lowerbound)
    26.     intEmp = (101 * Rnd)
    27. 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.

  10. #10

    Thread Starter
    Addicted Member
    Join Date
    Sep 2002
    Location
    India
    Posts
    151

    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

  11. #11
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051

    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.


  12. #12

    Thread Starter
    Addicted Member
    Join Date
    Sep 2002
    Location
    India
    Posts
    151

    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

  13. #13

    Thread Starter
    Addicted Member
    Join Date
    Sep 2002
    Location
    India
    Posts
    151

    Thanx

    Thanx for the help buddy
    Variety is the spice of life

  14. #14
    Need-a-life Member Mc Brain's Avatar
    Join Date
    Apr 2000
    Location
    Buenos Aires, Argentina
    Posts
    6,808
    Try this:
    Attached Files Attached Files
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width