Button Click

  1. Public Class Form1
  2. Private _currentSpeaker As Speaker = Speaker.SpeakerA
  3. Private Property CurrentSpeaker As Speaker
  4. Get
  5. Return _currentSpeaker
  6. End Get
  7. Set(value As Speaker)
  8. _currentSpeaker = value
  9. Me.Text = value.ToString()
  10. End Set
  11. End Property
  12.  
  13. Private Enum Speaker As Integer
  14. SpeakerA = 0
  15. SpeakerB = 1
  16. End Enum
  17.  
  18. Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  19. CurrentSpeaker = Speaker.SpeakerA
  20. End Sub
  21.  
  22. Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
  23. CurrentSpeaker = Speaker.SpeakerB
  24. End Sub
  25.  
  26. Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
  27. Select Case CurrentSpeaker
  28. Case Speaker.SpeakerA
  29. TextBox1.AppendText("huhu ")
  30. Case Speaker.SpeakerB
  31. TextBox1.Clear()
  32. TextBox1.Text = "huhuuuuu"
  33. End Select
  34. End Sub
  35. End Class

Test

Public Class AdvancedTimer 

 

Private m_StopWatch As Stopwatch Private m_Timer As Windows.Forms.Timer Private m_Interval As Integer = 1000 

 

Public Event Tick(ByVal sender As Object, ByVal e As EventArgs) 

 

Public Event StatusChanged(ByVal sender As Object, ByVal e As AdvancedTimerEventArgs) 

 

Public Sub New()

 

m_Timer = New Windows.Forms.Timer With {

 

.Enabled = False, .Interval = 100

 

}

 

AddHandler m_Timer.Tick, AddressOf iTick m_StopWatch = New Stopwatch 

 

End Sub Public Property Interval() As Integer Get 

 

Return m_Interval End Get Set(ByVal value As Integer) 

 

If value < 100 

 

Then Throw New Exception("Interval kann nicht kleiner 100 sein.") 

 

Else m_Interval = value 

 

End