' OldMcDonald1 Example ' Input an animal name and sound, output a verse ' from the Old McDonald song. Public Class Form1 Inherits System.Windows.Forms.Form #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 End Sub 'Form 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 txtAnimal As System.Windows.Forms.TextBox Friend WithEvents txtSound As System.Windows.Forms.TextBox Friend WithEvents btnShow As System.Windows.Forms.Button Friend WithEvents txtSong As System.Windows.Forms.TextBox Private Sub InitializeComponent() Me.txtAnimal = New System.Windows.Forms.TextBox Me.txtSound = New System.Windows.Forms.TextBox Me.btnShow = New System.Windows.Forms.Button Me.txtSong = New System.Windows.Forms.TextBox Me.SuspendLayout() ' 'txtAnimal ' Me.txtAnimal.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.txtAnimal.Location = New System.Drawing.Point(16, 16) Me.txtAnimal.Name = "txtAnimal" Me.txtAnimal.Size = New System.Drawing.Size(144, 29) Me.txtAnimal.TabIndex = 1 Me.txtAnimal.Text = "" ' 'txtSound ' Me.txtSound.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.txtSound.Location = New System.Drawing.Point(168, 16) Me.txtSound.Name = "txtSound" Me.txtSound.Size = New System.Drawing.Size(144, 29) Me.txtSound.TabIndex = 2 Me.txtSound.Text = "" ' 'btnShow ' Me.btnShow.Location = New System.Drawing.Point(320, 16) Me.btnShow.Name = "btnShow" Me.btnShow.Size = New System.Drawing.Size(88, 32) Me.btnShow.TabIndex = 3 Me.btnShow.Text = "Show" ' 'txtSong ' Me.txtSong.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.txtSong.Location = New System.Drawing.Point(16, 56) Me.txtSong.Multiline = True Me.txtSong.Name = "txtSong" Me.txtSong.Size = New System.Drawing.Size(392, 256) Me.txtSong.TabIndex = 4 Me.txtSong.Text = "" ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(10, 22) Me.ClientSize = New System.Drawing.Size(424, 326) Me.Controls.Add(Me.txtSong) Me.Controls.Add(Me.btnShow) Me.Controls.Add(Me.txtSound) Me.Controls.Add(Me.txtAnimal) Me.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Name = "Form1" Me.Text = "OldMcDonald Example" Me.ResumeLayout(False) End Sub #End Region Private Sub btnShow_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles btnShow.Click ShowSong(txtAnimal.Text, txtSound.Text) End Sub Private Sub ShowSong(ByVal animal As String, _ ByVal sound As String) Dim output As String = "" Dim n As String = ControlChars.NewLine output &= "Old McDonald had a farm." & n output &= "Ee-ay-ee-ay-oh." & n output &= "And on that farm he had a " & animal & "." & n output &= "Ee-ay-ee-ay-oh." & n & n output &= "With a " & sound + ", " & sound + " here," & n output &= "And a " & sound + ", " & sound + " there," & n output &= "Here a " & sound + "," & n output &= "There a " & sound + "," & n output &= "Everywhere a " & sound + ", " & sound & "." _ & n & n output &= "Old McDonald had a farm." & n output &= "Ee-ay-ee-ay-oh." & n output &= "And on that farm he had a " & animal & "." & n output &= "Ee-ay-ee-ay-oh." & n txtSong.Text = output End Sub End Class