タイトル : Delgateの受け渡し? 投稿日 : 2009/03/13(Fri) 10:12 投稿者 : ダンボ
お世話になっております。VB2005のTimerクラスをちょっと改良しようとして 下記コード(未完成)を作成中ですが、2箇所のAddressOf MyClass.EventProcで コンパイルエラーが出ており解決策がわかりません。 エラーメッセージは、 「'AddressOf' オペランドはメソッドの名前でなければなりません。かっこは不要です。」 Public Class EventArgsSlideTimer Inherits System.EventArgs Public Profile As ProfileClass Public Sub New(ByVal Profile As ProfileClass) MyClass.Profile = Profile End Sub End Class Public Class SlideTimerClass Inherits System.Windows.Forms.Timer Private SlideProfile As ProfileClass Private EventProc As Predicate(Of EventHandler(Of EventArgsSlideTimer)) Public Sub New(ByVal SlideProfile As ProfileClass, ByVal EventProc As Predicate(Of EventHandler(Of EventArgsSlideTimer))) MyClass.SlideProfile = SlideProfile MyClass.EventProc = EventProc AddHandler MyClass.Tick, AddressOf MyClass.EventProc End Sub Protected Overrides Sub Finalize() RemoveHandler MyClass.Tick, AddressOf MyClass.EventProc MyClass.Finalize() End Sub End Class |