掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
VB.netのTimerをVBのようにコントロール配列にして使用するには? (ID:77919)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
> TickイベントがどのTimerでおきているのが分からないのですが... この場合は、 > Private Sub subTimer_Tick(ByVal myObject As Object, _ > ByVal e As EventArgs) の「myObject」が指し示すTimerで起きている事になります。 識別用に、Timerを継承したクラスを作っておくと良いかも。 '「Indexプロパティ」を追加したTimerを定義 Class TimerEx Inherits System.Windows.Forms.Timer Public Index As Integer Public Sub New(ByVal Index As Integer) Me.Index = Index End Sub End Class Public myTimer(2) As System.Windows.Forms.Timer Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim ii As Integer For ii = 0 To 2 myTimer(ii) = New TimerEx(ii) myTimer(ii).Interval = 500 myTimer(ii).Enabled = False AddHandler myTimer(ii).Tick, AddressOf subTimer_Tick Next myTimer(0).Start() myTimer(1).Start() myTimer(2).Start() End Sub Private Sub subTimer_Tick(ByVal myObject As Object, ByVal e As EventArgs) Me.ListBox1.Items.Add("発生:" & DirectCast(myObject, TimerEx).Index) End Sub
←解決時は質問者本人がここをチェックしてください。
戻る
掲示板システム
Copyright 2020 Takeshi Okamoto All Rights Reserved.