Option Strict On
Imports System.ComponentModel
Imports System.Windows.Forms
Imports System.Drawing
Public Class MyForm
Inherits Form
Private box As TextBox
Private WithEvents myButton As Button
Public Sub New()
box = New TextBox()
box.BackColor = System.Drawing.Color.Cyan
box.Size = New Size(100, 100)
box.Location = New Point(50, 50)
box.Text = "Hello"
myButton = New Button()
myButton.Location = New Point(50, 100)
myButton.Text = "Click Me"
AddHandler myButton.Click, AddressOf Me.Button_Click
Controls.Add(box)
Controls.Add(myButton)
End Sub
Private Sub Button_Click(sender As Object, e As EventArgs)
box.BackColor = System.Drawing.Color.Green
End Sub
<STAThreadAttribute()> _
Public Shared Sub Main(args() As String)
Application.Run(New MyForm())
End Sub
End Class
|