Please help me in this VB question Dim pupil As Student Private Sub btnGo_Click(
ID: 3574496 • Letter: P
Question
Please help me in this VB question
Dim pupil As Student
Private Sub btnGo_Click(....) Handles btnGo.Click
Dim grade As String
pupil = New Student()
pupil.CalcSemGrade = “A”
grade = pupil.CalcSemGrade()
End Sub
(a) Determine the error(s), if any, in the given code segment, shown below.
(b).Now, you are required to (replace) only the statement (s) that you have identified as erroneous in part, and write your corrected code statements,necessary to obtain the desired results.
Explanation / Answer
Private Sub btnGo_Click(sender As Object, e As EventArgs) Handles btnGo.Click
Dim grade As String
Dim pupil As Student = New Student()
pupil.CalcSemGrade = "A"
grade = pupil.CalcSemGrade()
End Sub
Class Student
Private grade As String
Public Sub New() 'This is the constructor
End Sub
Public Property CalcSemGrade() As String
Get
Return grade
End Get
Set(value As String)
grade = value
End Set
End Property
End Class
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.