Question Classes

fabiomarcos

Member
Joined
Oct 21, 2008
Messages
5
Programming Experience
Beginner
Hi !
I have a class declared like this:
VB.NET:
Public class xStudent
  Public Sub eraseProfile
     ... erase file here
  End Sub
  Public Sub createProfile
    ... create profile here
  End Sub
End Class
I can call eraseProfile and createProfile as usual, but I would like to know, if is possible to (and How to) use this class like:
_student.Profile.Erase() and
_student.Profile.Create()
Instead of
_student.createProfile() and
_Student.eraseProfile().

I would like to create methods for "profile" (create, use, erase,...)

Thank's in advance !
 
One of the wonderful things about object oriented programming is the ability to nest. You simple need to create another class that represents the Profile, then store that within the xStudent class.

Pseudo code
VB.NET:
Public class xStudent
  Dim studentProfile as New Profile
End Class

Public Class Profile
  Public Sub eraseProfile
     ... erase file here
  End Sub
  Public Sub createProfile
    ... create profile here
  End Sub
End Class

This would give you a student.Profile.createProfile, etc.

[As a final note, others may say differently but I also discourage the use of underscores to denote private members. I've always seen this as a hold up from the days of C/C++ programming and unnecessary in VB.NET. Totally just my two cents worth though.]
 
No matter what I do in the Profile's sub... it just could be a simple "Hello World"...
What a really want to know is how to implement a class or something where I could use:

_student.Something.DoIt1 and _student.Something.Doit2 instead of

_student.SomethingDoIt1 or _student.SomethingDoIt2

Thank's Raven65

That's is what I needed !
You got the point.
 
Back
Top