2 on page 563 and exercise 8 and 12 on page 564 Can somebody sent me the OBJECT,
ID: 3826882 • Letter: 2
Question
2 on page 563 and exercise 8 and 12 on page 564
Can somebody sent me the OBJECT, PROPERTY, SETTING. : ;please
Introduction to programming using visual basic (10th Edition) Chapter 11.1
Dim Scholar As Student
Private Sub btnGo_Click (...) Handles btnGo.Click
Dim firstName as String
Scholar.Name = "Warren"
firstName = Scholar.Name
End Sub
Dim Scholar As Student
Private Sub btnGo_Click (...) Handles btnGo_Click
Dim nom As String
Scholar.Name = "Warren Peace"
nom = m_name
End Sub
Can you sent me the
Object Property setting
The text book solution is not showing it please!
Explanation / Answer
Student is a class which has a member variable to hold the name of the Student. To set set property for the object created, first we need to define the Name property in the Student class with get and set properties
First create a class Student.vb for the application. Below is the code for Student.vb
Public Class Student
'here stu_name is the member variable to hold the name
Private stu_name As String
'define property Name
Public Property Name() As String
'return stu_name in Get method
Get
Return stu_name
End Get
'set stu_name in Set method, here value is the string used to set name
Set(value As String)
stu_name = value
End Set
End Property
End Class
Now, that the Name property is set in the form we can create an object for Student class and use Property to set it
As the form details are not mention, i used a form which has just one button say Go, and on the button click i used the property to set the name, to ensure that the name is set i displayed it in the Message box using the get method of the property. Here is the code in Form1
Public Class Form1
Dim scholar As New Student
Private Sub btnGo_Click(sender As System.Object, e As System.EventArgs) Handles btnGo.Click
Dim nom As String
scholar.Name = "Warren Peace"
nom = scholar.Name
MessageBox.Show(nom)
End Sub
End Class
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.