Public Class MyControl
    Inherits System.Windows.Forms.UserControl

    ' members...
    Private _messageText As String

    ' events...
    Event HelloWorld(ByVal sender As Object, ByVal e As System.EventArgs)

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call
        MessageText = "Hello, world!"
    End Sub

    'UserControl overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents btnSayHello As System.Windows.Forms.Button
    Friend WithEvents btnSaySomething As System.Windows.Forms.Button
    Friend WithEvents btnSaySomethingElse As System.Windows.Forms.Button
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.btnSayHello = New System.Windows.Forms.Button()
        Me.btnSaySomething = New System.Windows.Forms.Button()
        Me.btnSaySomethingElse = New System.Windows.Forms.Button()
        Me.SuspendLayout()
        '
        'btnSayHello
        '
        Me.btnSayHello.Location = New System.Drawing.Point(8, 8)
        Me.btnSayHello.Name = "btnSayHello"
        Me.btnSayHello.Size = New System.Drawing.Size(136, 23)
        Me.btnSayHello.TabIndex = 0
        Me.btnSayHello.Text = "Say, ""Hello, world!"""
        '
        'btnSaySomething
        '
        Me.btnSaySomething.Location = New System.Drawing.Point(8, 40)
        Me.btnSaySomething.Name = "btnSaySomething"
        Me.btnSaySomething.Size = New System.Drawing.Size(136, 23)
        Me.btnSaySomething.TabIndex = 1
        Me.btnSaySomething.Text = "Say Something"
        '
        'btnSaySomethingElse
        '
        Me.btnSaySomethingElse.Location = New System.Drawing.Point(8, 72)
        Me.btnSaySomethingElse.Name = "btnSaySomethingElse"
        Me.btnSaySomethingElse.Size = New System.Drawing.Size(136, 23)
        Me.btnSaySomethingElse.TabIndex = 2
        Me.btnSaySomethingElse.Text = "Say Something Else"
        '
        'MyControl
        '
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.btnSaySomethingElse, Me.btnSaySomething, Me.btnSayHello})
        Me.Name = "MyControl"
        Me.Size = New System.Drawing.Size(152, 104)
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Sub btnSayHello_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSayHello.Click
        ' raise the event...
        RaiseEvent HelloWorld(Me, New System.EventArgs())

        MsgBox(_messageText)
    End Sub

    Private Sub btnSaySomething_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSaySomething.Click
        MsgBox("Something!")
    End Sub

    Private Sub btnSaySomethingElse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSaySomethingElse.Click
        MsgBox("Something else!")
    End Sub

    Public Property MessageText() As String
        Get
            Return _messageText
        End Get
        Set(ByVal Value As String)

            ' set the text...
            _messageText = Value

            ' update the button...
            btnSayHello.Text = "Say """ & _messageText & """"

        End Set
    End Property

    Public Sub ResetMessageText()
        MessageText = "Hello, world!"
    End Sub

    Private Sub MyControl_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub
End Class
