19.12.2012 Views

Computer Programming Concepts and Visual Basic David I. Schneider

Computer Programming Concepts and Visual Basic David I. Schneider

Computer Programming Concepts and Visual Basic David I. Schneider

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

368 <strong>Computer</strong> <strong>Programming</strong> <strong>Concepts</strong> <strong>and</strong> <strong>Visual</strong> <strong>Basic</strong><br />

Property Get Name() As String<br />

Name = m_name<br />

End Property<br />

Property Let Name(ByVal vName As String)<br />

m_name = vName<br />

End Property<br />

Property Get SocSecNum() As String<br />

SocSecNum = m_ssn<br />

End Property<br />

Property Let SocSecNum(ByVal vNum As String)<br />

m_ssn = vNum<br />

End Property<br />

Property Let midGrade(ByVal vGrade As Single)<br />

m_midterm = vGrade<br />

End Property<br />

Property Let finGrade(ByVal vGrade As Single)<br />

m_final = vGrade<br />

End Property<br />

Public Function SemGrade() As String<br />

Dim grade As Single<br />

grade = (m_midterm + m_final) / 2<br />

grade = Round(grade) ‘Round the grade<br />

If grade = 60 Then<br />

SemGrade = “Pass”<br />

Else<br />

SemGrade = “Fail”<br />

End If<br />

End Function<br />

‘Form code<br />

Dim section As New Collection<br />

Private Sub cmdAdd_Click()<br />

Dim pupil As Object<br />

If optReg.Value Then<br />

Set pupil = New CSTudent<br />

Else<br />

Set pupil = New CPFStudent<br />

End If<br />

‘Read the Values stored in the Text boxes<br />

pupil.Name = txtName<br />

pupil.SocSecNum = txtSSN<br />

pupil.midGrade = Val(txtMidterm)<br />

pupil.finGrade = Val(txtFinal)<br />

section.Add pupil<br />

‘Clear Text Boxes<br />

txtName.Text = “”<br />

txtSSN.Text = “”<br />

txtMidterm.Text = “”

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!