Hi, I'm trying to raise an event from a class. It looks ok but it did not raise the event as expected...? Anyone as a solution ?
Steps
1 - Load the form2
2 - Boutton1 call the form1 and load the class animation
3 - Class animation raise the event for the form1
Here is the code !
Public Class Form1
Private WithEvents AnimationTextChange As Animation
Public Sub mdiMainEvent_StatusTextChange(ByVal _text As String) Handles AnimationTextChange.StatusTextChange
MessageBox.Show(_text)
End Sub
End Class
Public Class Form2
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Show the form
Dim _Form As New Form1
_Form.Show()
'Call the class
Dim x As New Animation
x.ChangeAnimationText(TextBox1.Text)
End Sub
End Class
Public Class Animation
Public Event StatusTextChange(ByVal text As String)
Sub ChangeAnimationText(ByVal text As String)
RaiseEvent StatusTextChange(text)
End Sub
End Class
Steps
1 - Load the form2
2 - Boutton1 call the form1 and load the class animation
3 - Class animation raise the event for the form1
Here is the code !
Public Class Form1
Private WithEvents AnimationTextChange As Animation
Public Sub mdiMainEvent_StatusTextChange(ByVal _text As String) Handles AnimationTextChange.StatusTextChange
MessageBox.Show(_text)
End Sub
End Class
Public Class Form2
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Show the form
Dim _Form As New Form1
_Form.Show()
'Call the class
Dim x As New Animation
x.ChangeAnimationText(TextBox1.Text)
End Sub
End Class
Public Class Animation
Public Event StatusTextChange(ByVal text As String)
Sub ChangeAnimationText(ByVal text As String)
RaiseEvent StatusTextChange(text)
End Sub
End Class