p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   VB How-To (http://p2p.wrox.com/forumdisplay.php?f=78)
-   -   Project.Class.Property. ? (http://p2p.wrox.com/showthread.php?t=439)

Jstmehr4u3 June 11th, 2003 11:02 AM

Project.Class.Property. ?
Ok. For instance ADO has

Adodb is the project, Recordset is the Class, Field is the property, what is Value? Sub Property?

I want to add a Size property associated to my Name Property inside my class. (So you get the . List in vb when you use the Name Property)

How do I do this?

Hal Levy June 11th, 2003 11:10 AM

ADODB.RECORDSET.Field returns an object as the result of the property. VB is smart when you say .VALUE and says "hey, lets get the object and then take that and do a .value to it)

it's like doing this:

myField = ADODB.Recordset.Field("FieldName")
myValue = myField.Value

Now, I am not sure why you would want a size property- as Name is likely to be of type String. String in itself is an object and you can use the name object and use .length on the string to find out it's length.

Hal Levy
Daddyshome, LLC

Hal Levy June 11th, 2003 11:12 AM

I just realized this is VB- not VB.NET...

In that case use len(myName) and get the length of the string.

Hal Levy
Daddyshome, LLC

Jstmehr4u3 June 11th, 2003 01:37 PM

Well, I just used Name for instance.
I have a class that sends messages. Each message has its own set of rules for each property. IsRequired, MaxLength, DataType.

I want the application to be able to test the data going into the class before it gets there, based on the rules (or properties) for each property.
For instance:
dim myClass as new Transactions.NewMessage
if MyClass.MessageBody.IsRequired then
  if len(MyVariableGoingToClass) <> MyClass.MessageBody.MaxLength then error
end if

Some other properties may have a SubRoutine associated to that property, Like:

So when you look at the entire hierarchy, you see:

How would I do that?

Hal Levy June 11th, 2003 03:10 PM

Depends on the design and the language.. In .NET
One way is create a method .build() on the messagebody class... The messagebody class could be a class inherited from string, so you only need to make your one method.

The MyClass.MessageBody property would return a MessageBody Object.

Hal Levy
Daddyshome, LLC

All times are GMT -4. The time now is 06:04 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.