AddReference "System.Drawing" ' Imports System.ComponentModel Imports System.Drawing Imports System.Windows.Forms Public Class WinForm Inherits System.Windows.Forms.Form 'declare anything here that you want to use/access throughout all Subs & Functions Public oLargerFont As System.Drawing.Font = New Font("Arial", 10) Public oOriginalText As String = "Your interactive text here." Public Sub New() 'creates the new instance Dim oForm As System.Windows.Forms.Form = Me With oForm .FormBorderStyle = FormBorderStyle.FixedToolWindow .StartPosition = FormStartPosition.CenterScreen .Width = 300 .Height = 300 .TopMost = True .Font = oLargerFont .Text = "Windows Form" .Name = "Windows Form" .ShowInTaskbar = False End With AddHandler oForm.FormClosing, AddressOf oForm_FormClosing Dim oButton1 As New Button() With oButton1 .Text = "TEST ME" .Top = 25 .Left = 25 .Enabled = True .AutoSize = True End With oForm.Controls.Add(oButton1) AddHandler oButton1.Click, AddressOf oButton1_Click Dim oTextBox As New TextBox() With oTextBox .Text = oOriginalText .Top = oButton1.Bottom + 10 .Left = 25 .Width = 250 .Height = 25 End With 'This works, but is extremely annoying, because every little space, delete, or keyboard character triggers it. 'AddHandler oTextBox.TextChanged, AddressOf oTextBox_TextChanged 'once the focus is within the TextBox, this event lets you know when the focus leaves it 'this is set to trigger the Sub below which checks the contents of the TextBox 'to see if anything has changed from the default value. AddHandler oTextBox.Leave, AddressOf oTextBox_Leave oForm.Controls.Add(oTextBox) Dim oCheckBox As New CheckBox() With oCheckBox .Text = "Activate Option/Setting?" .Top = oTextBox.Bottom + 10 .Left = 25 .AutoSize = True End With AddHandler oCheckBox.CheckedChanged, AddressOf oCheckBox_CheckedChanged oForm.Controls.Add(oCheckBox) Dim oOptions As New List(Of String) oOptions.AddRange({"Option 1","Option 2","Option 3"}) Dim oComboBox As New ComboBox() With oComboBox .DropDownStyle = ComboBoxStyle.DropDownList .Items.Clear() .Items.AddRange(oOptions.ToArray) .SelectedIndex = 1 .Top = oCheckBox.Bottom + 10 .Left = 25 .Width = 150 End With AddHandler oComboBox.SelectionChangeCommitted, AddressOf oComboBox_SelectionChangeCommitted oForm.Controls.Add(oComboBox) Dim oRadioButton1 As New RadioButton() AddHandler oRadioButton1.CheckedChanged, AddressOf oRadioButton1_CheckedChanged oForm.Controls.Add(oRadioButton1) ' oRadioButton1.Checked = True 'you can use this to set a default oRadioButton1.Text = "Choice 1" oRadioButton1.Top = oComboBox.Bottom + 20 oRadioButton1.Left = 25 oRadioButton1.AutoSize = True Dim oRadioButton2 As New RadioButton() ' AddHandler oRadioButton2.CheckedChanged, AddressOf oRadioButton2_CheckedChanged oForm.Controls.Add(oRadioButton2) oRadioButton2.Text = "Choice 2" oRadioButton2.Top = oRadioButton1.Bottom + 10 oRadioButton2.Left = 25 oRadioButton2.AutoSize = True End Sub 'This is the end of the main Sub that defines the Form Private Sub oForm_FormClosing(ByVal oSender As Object, ByVal oFormCloseEvents As FormClosingEventArgs) ''oSender is a Form If MsgBox("Are you sure you want to close this Form?", vbYesNo + vbQuestion, "CLOSE") = vbYes Then Else oFormCloseEvents.Cancel = True End If End Sub Private Sub oButton1_Click(ByVal oSender As System.Object, ByVal oEventArgs As System.EventArgs) MsgBox("You just clicked the [" & oSender.Text & "] button.", vbOKOnly + vbInformation, "EVENT FEEDBACK") End Sub ' This works, but Is extremely annoying, because every little Space, delete, or keyboard character triggers it. ' Private Sub oTextBox_TextChanged(ByVal oSender As System.Object, ByVal oEventArgs As System.EventArgs) ' MsgBox("The contents of the TextBox have changed.", vbOKOnly + vbInformation, "EVENT FEEDBACK") ' End Sub Private Sub oTextBox_Leave(ByVal oSender As System.Object, ByVal oEventArgs As System.EventArgs) If oSender.Text <> oOriginalText Then MsgBox("The contents of the TextBox have changed.", vbOKOnly + vbInformation, "EVENT FEEDBACK") End If End Sub Private Sub oCheckBox_CheckedChanged(ByVal oSender As System.Object, ByVal oEventArgs As System.EventArgs) 'oSender is a CheckBox If oSender.Checked = True Then MsgBox("You just Checked the [" & oSender.Text & "] checkbox.", vbOKOnly + vbInformation, "EVENT FEEDBACK") Else MsgBox("You just UnChecked the [" & oSender.Text & "] checkbox.", vbOKOnly + vbInformation, "EVENT FEEDBACK") End If End Sub Private Sub oComboBox_SelectionChangeCommitted(ByVal oSender As System.Object, ByVal oEventArgs As System.EventArgs) ' oSender is a ComboBox MsgBox("You just chose " & oSender.Text & " from the ComboBox.",vbOKOnly+vbInformation,"EVENT FEEDBACK") End Sub Private Sub oRadioButton1_CheckedChanged(ByVal oSender As System.Object, ByVal oEventArgs As System.EventArgs) If oSender.Checked Then 'oSender is a RadioButton MsgBox("You just changed the Radio Button option to '" & oSender.Text & "'.", vbOKOnly + vbInformation, "EVENT FEEDBACK") Else MsgBox("You just changed the Radio Button option to 'Choice 2'.", vbOKOnly + vbInformation, "EVENT FEEDBACK") End If End Sub ' Private Sub oRadioButton2_CheckedChanged(ByVal oSender As System.Object, ByVal oEventArgs As System.EventArgs) ' MsgBox("You just changed the Radio Button option to " & oSender.Text & ".",vbOKOnly+vbInformation,"EVENT FEEDBACK") ' End Sub End Class Public Class RunMyForm Private Sub Main Dim oMyForm As New WinForm oMyForm.Show End Sub End Class