Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Events??

Status
Not open for further replies.

Grog9999

Technical User
Nov 10, 2002
6
CA
I tried to make an event but it doesn't work and I just don't understand why

First of all I've got a class named Simulation in witch I putted my Event like that

Public Event TourDébuté(ByVal intNoTour As Integer)

Then in a Sub I Raise the envent like that:

For intTours = 0 To mintNbTours
For intCases = 0 To UBound(mobjaCases)
If Not mobjaCases(intCases) Is Nothing Then
mobjaCases(intCases).Reproduit = False
End If
Next intCases
RaiseEvent TourDébuté(intTours)
For intCases = 0 To UBound(mobjaCases).....
Next intTours


Then I want to use it in a form in witch I wrote:

Private WithEvents mclsSimulation As Simulation


And finally I've made:

Private Sub mclsSimulation_TourDébuté(ByVal intNoTour As Integer)
lblÉtatSimulation.Caption = "Tour no." & intNoTour & " sur " & mclsSimulation.NbTours
End Sub


The purpose of it is to change my label when the event raise
Please help if you can

Thank
Grog
 
‘ I have a class module named Class1. Below is the code for Class1

Option Explicit
Public Event ChangeMyLabel(sValue As String)

Public Sub SetMyLabel()
RaiseEvent ChangeMyLabel("Text For Label")
End Sub


‘ The code below is from a form module with a command button named Command1. Command1 causes Class1’s ChangeMyLabel event to fire. . . which in turn sets Label1’s caption

Option Explicit
Dim WithEvents objLabelThing As Class1

Private Sub Command1_Click()
objLabelThing.SetMyLabel
End Sub

Private Sub Form_Load()
Set objLabelThing = New Class1
End Sub

Private Sub objLabelThing_ChangeMyLabel(sValue As String)

Me.Label1 = sValue
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top