473,394 Members | 1,718 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Need help with simple class


Hello,

I created the class "document":

Public Class Document

Private Shared _title As String

Public Property Title() As String
Get
Return _title
End Get
Set(ByVal value As String)
If _title = value Then
Return
End If
_title = value
End Set
End Property

End Class

To set the property value I am using:

Dim MyDocument As New Document
MyDocument.Title = "My book title"

I need to be able to create "second level" properties. An example:

MyDocument.Author.Name = "Author Name"

Instead of having

MyDocument.AuthorName = "Author Name"

I inserted the class "Author", with property "Name" inside Class
Document.

It is not working. Could someone explain me how to create it?
Thank You,
Miguel

Jan 30 '06 #1
4 922
Can you provide some code and the error message?

"Miguel Dias Moura" <md*REMOVE*moura@gmail*NOSPAM*.com> wrote in message
news:ef**************@TK2MSFTNGP09.phx.gbl...

Hello,

I created the class "document":

Public Class Document

Private Shared _title As String

Public Property Title() As String
Get
Return _title
End Get
Set(ByVal value As String)
If _title = value Then
Return
End If
_title = value
End Set
End Property

End Class

To set the property value I am using:

Dim MyDocument As New Document
MyDocument.Title = "My book title"

I need to be able to create "second level" properties. An example:

MyDocument.Author.Name = "Author Name"

Instead of having

MyDocument.AuthorName = "Author Name"

I inserted the class "Author", with property "Name" inside Class Document.

It is not working. Could someone explain me how to create it?
Thank You,
Miguel

Jan 30 '06 #2
Declare a Public Variable of Type
Public Author as New Author and it shoule be available

Regards,
Trevor Benedict R
MCSD

"Miguel Dias Moura" <md*REMOVE*moura@gmail*NOSPAM*.com> wrote in message
news:ef**************@TK2MSFTNGP09.phx.gbl...

Hello,

I created the class "document":

Public Class Document

Private Shared _title As String

Public Property Title() As String
Get
Return _title
End Get
Set(ByVal value As String)
If _title = value Then
Return
End If
_title = value
End Set
End Property

End Class

To set the property value I am using:

Dim MyDocument As New Document
MyDocument.Title = "My book title"

I need to be able to create "second level" properties. An example:

MyDocument.Author.Name = "Author Name"

Instead of having

MyDocument.AuthorName = "Author Name"

I inserted the class "Author", with property "Name" inside Class Document.

It is not working. Could someone explain me how to create it?
Thank You,
Miguel

Jan 30 '06 #3
Looks like you need to create an Author Class that has a shared
property called Name which is a String
then,
In your Document class, create a Property with the name of Author that
returns a new Author object.

Therefore, you can access the the Name of the Author like:

MyDocument.Author.Name

Jan 30 '06 #4
correction: The Name property in the Author class should not be shared
if the Author propety in the Document Class returns a new Author. You
can't access a shared Property if the object is an instance. Hope
that's not too complicated.

Jan 30 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: keith bannister via .NET 247 | last post by:
(Type your message here) -------------------------------- From: keith bannister Hi, I'm new to .net (as of last week) but here goes. I want to serialize/deserialize a file the conforms...
5
by: Keith Bannister | last post by:
I'm new to .net so here goes. I'm tying to deserialize a class that is associated with an XML schema. I created the C# class with xsd.exe as below: xsd.exe /c /n:somenamespace...
2
by: Andrew S. Giles | last post by:
OK, Ive run my head into this wall for too long. I need help. I am developing an applicaiton in C# to present a user with a GUI to specify a configurable list of machines that he wants to listen...
3
by: LW | last post by:
Hi! I am getting the following error message for my fairly simple web service. I have classes and have two DataSets that reference the same classes. The error is: The XML element named...
25
by: Jon Slaughter | last post by:
I have some code that loads up some php/html files and does a few things to them and ultimately returns an html file with some php code in it. I then pass that file onto the user by using echo. Of...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.