• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 289
  • Last Modified:

Determine the errors in the given code form

I am trying to identify the error in the following code:
 Dim scholar As Student
Private Sub btnGo_Click(...) Handles btnGo.Click
  Dim nom as String
  Scholar = New Student ()
  m_name = "Peace, Warren"
  nom = scholar.Name
End Sub

I think that the error comes in the line m_name = "Peace, Warren." I think that it should be replaced with "scholar.Name = "Peace, Warren,"" but I am not sure thought behind this reasoning; I think this based on the VB book that I am referencing.
Thanks for any assistance!
  • 2
1 Solution
Kiran SonawaneProject LeadCommented:
Yes. You are correct. It seems m_name is private field for Student class and Name is property of student class. If you want access property of any class you need to create instance of that class like scholar = New Student(); Then you can access the properties (public) of that class.

  Coming at m_name. If it is private field of Student class you can not access the private field outside that class. The scope of that filed is only for that class
kivakhimeraAuthor Commented:
Sorry that I didn't include this information before, but for this scenario m_name designates student name. I think that your answer is sufficient, but I thought I would throw this info out there and see if your answer changed at all. Thanks again!
Kiran SonawaneProject LeadCommented:
Show your Student class and will explain you...
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now