Help with class

  • Thread starter Thread starter gsb58
  • Start date Start date
G

gsb58

Hi!

As a training case I'm trying to build a class, in VB.NET, that will
hold my friends names, addresses, zipcodes and cities, emails, like
this:

Public Class ContaktsData

Public fName As String
Public lName As String
Public fAdr As String
Public fZip As String
Public fEmail As String


End Class

However...Can anybody help me out with a simple example on how to build
this class, or point me to an article that deals with this subject?

I want to store the information from a form to a .dat file I think in
the end.

Me.Name
 
:
: Hi!
:
: As a training case I'm trying to build a class, in VB.NET, that will
: hold my friends names, addresses, zipcodes and cities, emails, like
: this:
:
: Public Class ContaktsData
:
: Public fName As String
: Public lName As String
: Public fAdr As String
: Public fZip As String
: Public fEmail As String
:
:
: End Class
:
: However...Can anybody help me out with a simple example on how to
: build this class, or point me to an article that deals with this
: subject?
:
: I want to store the information from a form to a .dat file I think
: in the end.
:
: Me.Name


You've got a good start. Don't make the fields public however - access
then via properties. For example:

Public Property FirstName() As String
Get
Return fName
End Get
Set
fName = value
End Set
End Property


Secondly, you'll want a collection of the contacts. One approach would
be to reference the System.Collections namespace and declare a class
that inherits from CollectionBase (see the SDK documentation for an
example of how to implement this).


You'll also want some way of reading in the data as well as saving it
when you're done. So in addition to the logic needed to flesh out the
CollectionBase derived class, you'll probably want some functions to
load the existing data and save the new data from and to your .dat file.


Finally, create an application that will provide you with a way of
actually putting this class to work.


I hope this is what you were looking for. Good luck and have fun.


Ralf
--
 
Thanks Ralf!

I'll check the documentation.

This helps me on the way.

Me.Name
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top