title: Raising an event in .net example
body: <p>I am trying to create a basic example of raising an event in vb.net, and I am hoping that by studying it thoroughly I can upgrade the way my system receives data from serial port.</p>
  
  <p>Right now I have a system that receives the incoming data from serial port via timers, the problem is there are certain events in a system that conflicts in my timer. Because of this I am planning to change the way I received the data from serial ports, instead of timer I want to use vb.net raiseevent.</p>
  
  <p>Unfortunately I can't find a simple example on how to use this event, by searching thoroughly I saw the <strong>MSDN's</strong> post about this topic and <a href="https://msdn.microsoft.com/en-us/library/h7a2kh64(VS.80).aspx" rel="noreferrer">it is here</a>. So, how do I use this example? I tried using it below like that</p>
  
  <pre><code>Public Event TimeExpired(ByVal Status As String)
  Public Sub RaiseTimeExpiredEvent()
      RaiseEvent TimeExpired("Your time has run out")
      MessageBox.Show(TimeExpired())
  End Sub
  Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
      RaiseTimeExpiredEvent()
  End Sub
  </code></pre>
  
  <p>It's not working working, the error is</p>
  
  <blockquote>
    <p>Error 1   'Public Event TimeExpired(Status As String)' is an event, and cannot be called directly. Use a 'RaiseEvent' statement to raise an event.    C:\Users\Cary\Desktop\Projects\Testing\Testing\Testing\Form1.vb 5   25  Testing</p>
  </blockquote>
  
  <p>Because of that error I tried to do it like this</p>
  
  <pre><code>Class Form1
  Public Event TimeExpired(ByVal Status As String)
  Public Sub RaiseTimeExpiredEvent()
      RaiseEvent TimeExpired("Your time has run out")
      MessageBox.Show(TimeExpired())
  
  End Sub
  
  
  Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
      RaiseEvent TimeExpired()
  End Sub
  </code></pre>
  
  <p>End Class</p>
  
  <p>But the error states</p>
  
  <blockquote>
    <p>Error 2   Argument not specified for parameter 'Status' of 'Public Event TimeExpired(Status As String)'.  C:\Users\Cary\Desktop\Projects\Testing\Testing\Testing\Form1.vb 11  9   Testing</p>
  </blockquote>