Review from Week 1 and 3
Code snippets from Week 1
Button toggle logic
Private
Sub
btnToggle_Click(ByVal
sender As
System.Object, ByVal
e As
System.EventArgs) Handles
btnToggle.Click If btnToggle.Text = "&Answer" Then btnToggle.Text = "&Picture" txtAnswer.Visible = True picLogo.Visible = False Else btnToggle.Text = "&Answer" txtAnswer.Visible = False picLogo.Visible = True End If End Sub |
Radio Button Check Changed logic
Private
Sub
rdoBears_CheckedChanged(ByVal
sender As
Object,
ByVal
e As
System.EventArgs) Handles
rdoBears.CheckedChanged lblTeamName.Text = "Bears" picLogo.Image = picBears.Image End Sub |
Bold / Italic (Style) change logic
Private
Sub
chkItalic_CheckedChanged(ByVal
sender As System.Object, ByVal
e As System.EventArgs) Handles
chkItalic.CheckedChanged Dim myStyle As New FontStyle() myStyle = lblTeamName.Font.Style lblTeamName.Font = myFont txtAnswer.Font = myFont End Sub |
Font Size change logic
Private
Sub
nudSize_ValueChanged(ByVal
sender As
Object,
ByVal
e As
System.EventArgs) Handles
nudSize.ValueChanged Dim myFont As New Font(lblTeamName.Font.FontFamily, nudSize.Value, lblTeamName.Font.Style) lblTeamName.Font = myFont txtAnswer.Font = myFont End Sub |
Form Load to initialize user interface
Private
Sub
frmMain_Load(ByVal
sender As
Object,
ByVal
e As
System.EventArgs) Handles
MyBase.Load rdoBears.Checked = True txtAnswer.Text = "No, the images loaded into controls at design time " & _ "are stored in a project resource file, and compiled " & _ "into the executable" End Sub |
Source from Week 3
Example 1
Inheritance Example
This example extends the tax calculation project from last week by creating tax objects for individual states. Each state class inherits from the base tax class overriding the calculations as is necessary.
Example 2
Interface Example
A base class implements an interface and can not be instantiated directly. Three classes that inherit from the base also inherit the interface.
Assignment
Build a series of classes that inherit from a base class and implement two methods for each. Review the examples and use the shell as a starting point. You may enhance in any way that you would like, or simply implement the methods as required by the base class.