Expand|Select|Wrap|Line Numbers
- Public Class frmMain
- Inherits System.Windows.Forms.Form
- Private m_objName(2) As Course ' Client object
- Private m_intPosition As Integer = 0 ' current account
- Private Sub frmMain_Load(ByVal sender As System.Object, _
- ByVal e As System.EventArgs) Handles MyBase.Load
- Dim intCount As Integer ' counter variable
- ' array of course names
- Dim strCourseName() As String = _
- New String() {"Science", "History", "Math"}
- ' array of course numbers
- Dim strCourseNumber() As String = _
- New String() {"S123", "H123", "M123"}
- 'array of start date
- Dim strStartDate() As String = _
- New String() {"2/27/07", "2/28/07", "3/1/07"}
- 'array of start date
- Dim strEndDate() As String = _
- New String() {"4/10/07", "4/11/07", "4/12/07"}
- ' loop and create more course objects
- For intCount = 0 To m_objName.GetUpperBound(0)
- ' create new object and store into Client array
- m_objName(intCount) = New Course(strCourseName(intCount), _
- strCourseNumber(intCount), strStartDate(intCount), _
- strEndDate(intCount))
- Next
- End Sub
- Private Sub btnNext_Click(ByVal sender As System.Object, _
- ByVal e As System.EventArgs) Handles btnNext.Click
- m_intPosition += 1 ' increment position
- ' if position is last (top) object
- If m_intPosition > m_objName.GetUpperBound(0) Then
- m_intPosition = 0 ' set to first position in array
- DisplayInformation() ' display information
- Else
- DisplayInformation()
- End If
- End Sub
- Private Sub btnPrev_Click(ByVal sender As System.Object, _
- ByVal e As System.EventArgs) Handles btnPrev.Click
- m_intPosition -= 1 ' decrement position
- ' if position is last (bottom) object
- If m_intPosition < 0 Then
- ' set to last position in array
- m_intPosition = m_objName.GetUpperBound(0)
- DisplayInformation()
- Else
- DisplayInformation() ' display information
- End If
- End Sub
- ' display information
- Private Sub DisplayInformation()
- ' use m_intPosition as index for each object
- txtCourseName.Text = m_objName(m_intPosition).Name
- txtCourseNumber.Text = m_objName(m_intPosition).Number
- txtCourseStart.Text = _
- Convert.ToString(m_objName(m_intPosition).Start)
- txtCourseEnd.Text = _
- Convert.ToString(m_objName(m_intPosition).CEnd)
- End Sub ' DisplayInformation
- Private Sub btnCreate_Click(ByVal sender As System.Object, _
- ByVal e As System.EventArgs) Handles btnCreate.Click
- End Sub
- End Class ' frmMain