Yes,
You start a new class and just under the class name you use the keywords
'Inherits Label'.
Whatever properties, procedures and events you add to it extends what it can do.
Since you are not overriding any of the label's features the syntax should be straight forward.
Code:Public Class TimedLabel Inherits Label Private WithEvents LabelTimer As New Timer Public Property Interval() As Integer Get Return LabelTimer.Interval End Get Set(value As Integer) LabelTimer.Interval = value End Set End Property Public Sub Start() LabelTimer.Start() End Sub Public Sub [Stop]() LabelTimer.Stop() End Sub Private Sub LabelTimer_Tick(sender As System.Object, e As System.EventArgs) Handles LabelTimer.Tick LabelTimer.Stop() Me.Text = "" End Sub End Class ' In use Public Class Form1 Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click With TimedLabel1 .Text = "This is Message to be shown for five seconds" .Interval = 5000 .Start() End With End Sub End Class




Reply With Quote
