This document contains 14 code examples written by Noah Alderman on 4/14/16 for Chapter 2 exercises in a programming textbook. The code examples demonstrate basics of Visual Basic .NET including handling button clicks, changing label text, performing calculations, and displaying date/time. Each example contains a short description and code to accomplish a simple task related to the chapter exercise.
This document contains 14 code examples written by Noah Alderman on 4/14/16 for Chapter 2 exercises in a programming textbook. The code examples demonstrate basics of Visual Basic .NET including handling button clicks, changing label text, performing calculations, and displaying date/time. Each example contains a short description and code to accomplish a simple task related to the chapter exercise.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6
Public Class Form1
'Noah Alderman, 4/14/16 Chapter2 Exercise1'
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click, Label1.Click Label1.Text = "Noah Alderman" Label2.Text = "Vancouver" Label3.Text = "British Columbia" End Sub End Class Public Class Forml 'Noah Alderman, 4/14/16 Chapter2 Exercise2' Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Lable1.Text = "Lord Tweedsmuir Secondary" End Sub Private Sub ExitToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click Application.Exit() End Sub End Class Public Class Form1 'Noah Alderman, 4/14/16 Chapter2 Exercise3' Private Sub RadioButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.Click Label1.Text = "Sam Harris-Vocals/Guitar/Saxophone" Label2.Text = "Casey Harris-KeyBoards" Label3.Text = "Noah Feldshuh-Guitar" Label4.Text = "Adam Levin-Drums" Label5.Text = "" End Sub Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged Label1.Text = "Ryan Tedder-Vocals/Piano" Label2.Text = "Zach Filkins-Lead Guitar" Label3.Text = "Drew Brown-Rhythm Guitar/bass Guitar" Label4.Text = "Eddie Fisher-Drums" Label5.Text = "Brent Kutzle-Bass Guitar/Acoustic Guitar/Lead Guitar" End Sub Private Sub RadioButton3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton3.CheckedChanged Label1.Text = "Patrick Stump-Vocals/Piano/Keyboards/Rhythm Guitar" Label2.Text = "Joe Trohman-Lead Guitar Keyboards" Label3.Text = "Pete Wentz-Bass/Unclean Vocals" Label4.Text = "Andy Hurley-Drums/Percussion" Label5.Text = "" End Sub End Class
Public Class Form1
'Noah Alderman, 4/14/16 Chapter2 Exercise4' Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged Label2.Text = "New Haven" Label3.Text = "Connecticut" End Sub Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged Label2.Text = "Cloverdale" Label3.Text = "Canada" End Sub Private Sub RadioButton3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton3.CheckedChanged Label2.Text = "Cloverdale" Label3.Text = "Canada" End Sub Private Sub RadioButton4_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton4.CheckedChanged Label2.Text = "Cloverdale" Label3.Text = "Canada" End Sub Private Sub RadioButton5_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton5.CheckedChanged Label2.Text = "Cloverdale" Label3.Text = "Canada" End Sub End Class Public Class Form1 'Noah Alderman, 4/14/16 Chapter2 Exercise5' Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Label1.Text = "(a + b) + c = a +(b + c)" End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Label1.Text = "a+b=b+a" End Sub End Class Public Class Form1 'Noah Alderman, 4/14/16 Chapter2 Exercise6' Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Label1.Text = "HELLO!" End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Label1.Text = "GOODBYE!" End Sub End Class
Public Class Form1
'Noah Alderman, 4/14/16 Chapter2 Exercise7' Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnexpression1.Click Me.lblexpression2.Text = 2 * 3.14 * 15 End Sub End Class Public Class Form1 'Noah Alderman, 4/14/16 Chapter2 Excercise8 Private Sub btnExpression_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnExpression.Click Me.lblAnswer1.Text = 5 * 3 Me.lblAnswer2.Text = 5 + 5 + 3 + 3 End Sub
Private Sub ExitToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Handles ExitToolStripMenuItem.Click Application.Exit() End Sub End Class Public Class Form1 'Noah Alderman, 4/14/16 Chapter2 Exercise9 Private Sub ExitToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click Application.Exit() End Sub Private Sub btnAnswer_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAnswer.Click Me.lblAnswer.Text = (3.3 + 3.5 + 4.0 + 3.0) / 4 End Sub End Class
Public Class Form1
'Noah Alderman, 4/14/16 Chapter2 Exercise10' Private Sub ExitToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click Application.Exit() End Sub Private Sub TopLeftToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles TopLeftToolStripMenuItem.Click lblmove.Location = New Point(12, 24) End Sub Private Sub TopCenterToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles TopCenterToolStripMenuItem.Click lblmove.Location = New Point(193, 24) End Sub Private Sub TopRightToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TopRightToolStripMenuItem.Click lblmove.Location = New Point(409, 24) End Sub Private Sub MiddleLeftToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles MiddleLeftToolStripMenuItem.Click lblmove.Location = New Point(12, 138) End Sub Private Sub MiddleCenterToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles MiddleCenterToolStripMenuItem.Click lblmove.Location = New Point(193, 138) End Sub Private Sub MiddleRightToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles MiddleRightToolStripMenuItem.Click lblmove.Location = New Point(409, 138) End Sub Private Sub BottomLeftToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BottomLeftToolStripMenuItem.Click lblmove.Location = New Point(12, 295) End Sub Private Sub BottomCenterToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BottomCenterToolStripMenuItem.Click lblmove.Location = New Point(193, 295) End Sub Private Sub BottomRightToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BottomRightToolStripMenuItem.Click lblmove.Location = New Point(409, 295) End Sub End Class
Public Class Form1
'Noah Alderman, 4/14/16 Chapter2 Exercise11' Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click With Me.lblcity .Text = "Dallas" .AutoSize = True .TextAlign = ContentAlignment.MiddleCenter End With End Sub Private Sub ExitToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click Application.Exit() End Sub End Class Public Class Form1 'Noah Alderman, 4/14/16 Chapter2 Exercise12' Private Sub ProgramToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ProgramToolStripMenuItem.Click End Sub Private Sub ExitToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click Application.Exit() End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Label1.Text = "Hi!" End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Label1.Text = "Bye!" End Sub Private Sub HiToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles HiToolStripMenuItem.Click Label1.Text = "Hi!" End Sub Private Sub ByeToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ByeToolStripMenuItem.Click Label1.Text = "Bye!" End Sub End Class
Public Class Form1
'Noah Alderman, 4/14/16 Chapter2 Exercise13' Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Label1.Text = TimeString Label2.Text = DateString End Sub Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click Application.Exit() End Sub End Class