Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 'Get bigger number Dim num1, num2 As Double num1 = CDbl(txtfirstnum.Text) num2 = CDbl(txtsecondnum.Text) If (num1 > num2) Then ListBox1.Text = "The larger number is " & num1 ElseIf (num2 > num1) Then ListBox1.Items.Add("The larger number is " & num2) ElseIf (num1 = num2) Then ListBox1.Items.Add("These numbers are the same") End If End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click ' add numbers Dim a, b As Double Dim result As Double a = geta() b = getb() result = ListBox1.Items.Add(a + b) 'calcbigger (a, b) End Sub Function geta() As Double ' get first number Dim s As String Dim result As Double s = txtfirstnum.Text result = CDbl(s) Return result End Function Function getb() As Double ' get second number Dim s As String s = txtsecondnum.Text Return CDbl(s) End Function Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click 'clear the listbox ListBox1.Items.Clear() End Sub Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click 'ask if they want to exit program Dim n As Integer n = MsgBox("Are you sure you want to exit?")) If (n = MsgBoxResult.Yes) Then End If End Sub End Class _ Partial Class Form1 Inherits System.Windows.Forms.Form 'Form overrides dispose to clean up the component list. _ Protected Overrides Sub Dispose(ByVal disposing As Boolean) If disposing AndAlso components IsNot Nothing Then components.Dispose() 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. _ Private Sub InitializeComponent() Me.components = New System.ComponentModel.Container Me.Label1 = New System.Windows.Forms.Label Me.Label2 = New System.Windows.Forms.Label Me.txtfirstnum = New System.Windows.Forms.TextBox Me.txtsecondnum = New System.Windows.Forms.TextBox Me.Button1 = New System.Windows.Forms.Button Me.BindingSource1 = New System.Windows.Forms.BindingSource(Me.components) Me.Button2 = New System.Windows.Forms.Button Me.Button3 = New System.Windows.Forms.Button Me.Button4 = New System.Windows.Forms.Button Me.ListBox1 = New System.Windows.Forms.ListBox CType(Me.BindingSource1, System.ComponentModel.ISupportInitialize).BeginInit() Me.SuspendLayout() ' 'Label1 ' Me.Label1.AutoSize = True Me.Label1.Location = New System.Drawing.Point(56, 32) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(67, 13) Me.Label1.TabIndex = 0 Me.Label1.Text = "Number One" ' 'Label2 ' Me.Label2.AutoSize = True Me.Label2.Location = New System.Drawing.Point(56, 104) Me.Label2.Name = "Label2" Me.Label2.Size = New System.Drawing.Size(68, 13) Me.Label2.TabIndex = 1 Me.Label2.Text = "Number Two" ' 'txtfirstnum ' Me.txtfirstnum.Location = New System.Drawing.Point(135, 25) Me.txtfirstnum.Name = "txtfirstnum" Me.txtfirstnum.Size = New System.Drawing.Size(133, 20) Me.txtfirstnum.TabIndex = 2 ' 'txtsecondnum ' Me.txtsecondnum.Location = New System.Drawing.Point(135, 97) Me.txtsecondnum.Name = "txtsecondnum" Me.txtsecondnum.Size = New System.Drawing.Size(133, 20) Me.txtsecondnum.TabIndex = 3 ' 'Button1 ' Me.Button1.Location = New System.Drawing.Point(135, 136) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size(133, 45) Me.Button1.TabIndex = 4 Me.Button1.Text = "Bigger" Me.Button1.UseVisualStyleBackColor = True ' 'Button2 ' Me.Button2.Location = New System.Drawing.Point(165, 62) Me.Button2.Name = "Button2" Me.Button2.Size = New System.Drawing.Size(69, 21) Me.Button2.TabIndex = 6 Me.Button2.Text = "Add" Me.Button2.UseVisualStyleBackColor = True ' 'Button3 ' Me.Button3.Location = New System.Drawing.Point(59, 334) Me.Button3.Name = "Button3" Me.Button3.Size = New System.Drawing.Size(94, 35) Me.Button3.TabIndex = 7 Me.Button3.Text = "Clear" Me.Button3.UseVisualStyleBackColor = True ' 'Button4 ' Me.Button4.Location = New System.Drawing.Point(229, 334) Me.Button4.Name = "Button4" Me.Button4.Size = New System.Drawing.Size(94, 35) Me.Button4.TabIndex = 8 Me.Button4.Text = "Quit" Me.Button4.UseVisualStyleBackColor = True ' 'ListBox1 ' Me.ListBox1.FormattingEnabled = True Me.ListBox1.Location = New System.Drawing.Point(59, 200) Me.ListBox1.Name = "ListBox1" Me.ListBox1.Size = New System.Drawing.Size(293, 108) Me.ListBox1.TabIndex = 9 ' 'Form1 ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(477, 438) Me.Controls.Add(Me.ListBox1) Me.Controls.Add(Me.Button4) Me.Controls.Add(Me.Button3) Me.Controls.Add(Me.Button2) Me.Controls.Add(Me.Button1) Me.Controls.Add(Me.txtsecondnum) Me.Controls.Add(Me.txtfirstnum) Me.Controls.Add(Me.Label2) Me.Controls.Add(Me.Label1) Me.Name = "Form1" Me.Text = "Form1" CType(Me.BindingSource1, System.ComponentModel.ISupportInitialize).EndInit() Me.ResumeLayout(False) Me.PerformLayout() End Sub Friend WithEvents Label1 As System.Windows.Forms.Label Friend WithEvents Label2 As System.Windows.Forms.Label Friend WithEvents txtfirstnum As System.Windows.Forms.TextBox Friend WithEvents txtsecondnum As System.Windows.Forms.TextBox Friend WithEvents Button1 As System.Windows.Forms.Button Friend WithEvents BindingSource1 As System.Windows.Forms.BindingSource Friend WithEvents Button2 As System.Windows.Forms.Button Friend WithEvents Button3 As System.Windows.Forms.Button Friend WithEvents Button4 As System.Windows.Forms.Button Friend WithEvents ListBox1 As System.Windows.Forms.ListBox End Class