Hi,
I know this has been covered here and in the .public groups, but it
seems like it's been a while, especially around here, so I just thought
I'd ask again to see if anyone has figured out a new angle.
If I have a class MyClass--not a collection container but a
single-level class--that has a bunch of properties of different types,
I'd like to be able to reference them via the standard VBA syntax of
MyClass.Propert ies("MyProperty ")
or
MyClass.Item("M yProperty")
so that I could use variables instead of having to say
MyClass.MyPrope rty
to get and let.
Of course, I could create a whole collection myself to loop using the
Item/IEnumerator trick, but seems to me that kind of squashes the
usefulness of properties in the first place.
Thanks in advance. 24 5448
Since Access 2000 one can put properties into a Standard Module.
One can reference them as ModuleName.Prop ertyName
example (in a standard module called PseudoClass)
Dim mInput As Double
Public Property Let InputNumber(ByV al vInput As Double)
mInput = vInput
End Property
Public Property Get TwelfthRoot() As Double
TwelfthRoot = mInput ^ (1 / 12)
End Property
---------------------
somewhere else
PseudoClass.Inp utNumber = 29
MsgBox PseudoClass.Twe lfthRoot
'Shows
'---------------------------
'Microsoft Office Access
'---------------------------
'1.323934501112 41
'---------------------------
'OK
'---------------------------
That being said, one of the great values of Classes is that multiple
instances can be created. TTBOMK only one instance of a Standard module
can exist at one time.
As well, these properties seem to operate no differently than Subs and
Functions, (well maybe a bit slower).
Thanks, but that's not what I'm asking. To use your example, I want to
be able to do this.
MsgBox PseudoClass.Pro perties("Twelft hRoot")
So that I could potentially say
Dim strTest as string
strTest="Thirte enthRoot"
MsgBox PseudoClass.Pro perties(strTest )
That's a silly example, but if for example you want to return a bunch
of different properties with a single piece of code, you begin to see
how Class.Property is a limitation.
The following MSDN article shows how to make the Item property the default
property of a collection. It requires using Procedure Attributes, normally
set in Visual Studio 6. http://msdn.microsoft.com/library/de...seofbricks.asp
--
David Lloyd
MCSD .NET http://LemingtonConsulting.com
This response is supplied "as is" without any representations or warranties.
"downwitch" <do*******@gmai l.com> wrote in message
news:11******** *************@g 49g2000cwa.goog legroups.com...
Hi,
I know this has been covered here and in the .public groups, but it
seems like it's been a while, especially around here, so I just thought
I'd ask again to see if anyone has figured out a new angle.
If I have a class MyClass--not a collection container but a
single-level class--that has a bunch of properties of different types,
I'd like to be able to reference them via the standard VBA syntax of
MyClass.Propert ies("MyProperty ")
or
MyClass.Item("M yProperty")
so that I could use variables instead of having to say
MyClass.MyPrope rty
to get and let.
Of course, I could create a whole collection myself to loop using the
Item/IEnumerator trick, but seems to me that kind of squashes the
usefulness of properties in the first place.
Thanks in advance.
lylefair wrote: Since Access 2000 one can put properties into a Standard Module. One can reference them as ModuleName.Prop ertyName
I was curious, so I have verified that this works in AC97 as well.
--
Bri
While I appreciate the attempts to help, please take a moment to read
the subject line and the first post before so doing.
I am intimately familiar with constructing classes and collections. I
am trying to find a workaround to the fact that VBA will let you build,
set, let, get, etc. a property, but does not expose the properties as a
native collection through which one can loop as one does through any
other native collection, such as a form's properties, or yes, as one
does through a collection object. I don't hold out much hope, but I
figured it was worth dashing the little bit I had for good, and this
would be the place to do it.
I misread your post. Me Bad. Sorry!
Not a problem. All in a day's work!
lylefair wrote: I misread your post. Me Bad. Sorry!
"downwitch" <do*******@gmai l.com> wrote in
news:11******** **************@ g44g2000cwa.goo glegroups.com: That's a silly example, but if for example you want to return a bunch of different properties with a single piece of code, you begin to see how Class.Property is a limitation.
What you're asking for is a collection that you can walk to get the
properties.
There is no way to do this in Access class modules. THe only way to
implement it is either with a custom collection or an array stored
in class module, with an interface for allowing you to enumerate its
values. I don't believe an array can be a public member, but you
should be able to create a public property of type array.
I've only wanted to walk the properties collection of a class module
internally, never externally, so I've only implemented it with an
array.
But once you're at that point, you have to ask yourself:
1. will you allocate a variable for each property, then double enter
it into an array?
OR
2. will you use the array for storing all the properties, and then
have the property LET/GETs operate directly on the array, and
completely ignore internal variables.
I don't know if the latter slows things down.
The former is easy enough, and that was how I implemented it, but I
was adding functionality to a class that was already in list, so I
needed backward compatibility.
--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
"downwitch" <do*******@gmai l.com> wrote in
news:11******** *************@o 13g2000cwo.goog legroups.com: I am intimately familiar with constructing classes and collections. I am trying to find a workaround to the fact that VBA will let you build, set, let, get, etc. a property, but does not expose the properties as a native collection through which one can loop as one does through any other native collection, such as a form's properties, or yes, as one does through a collection object. I don't hold out much hope, but I figured it was worth dashing the little bit I had for good, and this would be the place to do it.
I posted in response to Lyle and explained one approach I've used.
It involves creating either your own internal custom collection or
an array to store the properties, then exposing that externally in
some fashion.
Having done it before, I immediately grasped the question -- you
want to be able to walk the properties collection of your class.
I use a class for storing the criteria for query-by-form interfaces,
and when writing the SQL, being able to walk a collection in order
to write the WHERE string would have been highly desirable. I
implemented an internal array, so I avoided the problems associated
with making the contents of an array in a class module public.
--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: raymi |
last post by:
Hi,
I have a custom class that gets its properties dynamically from a
database at runtime. Therefore I implemented the ICustomTypeDescriptor
in this class and created a a custom PropertyDescriptor. The custom
class also inherits from Component and therefore can be dragged on the
form in the designer view.
So far so good, I can bind properties from my class to textboxes etc.
But when I try to bind an ArrayList containig instances of my...
|
by: Imar Spaanjaars |
last post by:
Hi there,
Can anyone tell me how to perform two-way binding with custom properties in
ASP.NET 2? Let's say I have a custom class called Person that I want to bind
to a FormView (using an ObjectDataSource) for editing . The Person class
exposes an Address property which in turn has ZipCode and City properties
(both strings).
How do I bind these to my FormView control? I tried Bind("Address.ZipCode")
but I got an error stating I should...
|
by: Steve Franks |
last post by:
Is there a way I can extend the HttpContext or one of its subclasses to
include a property that exposes a custom class of mine to all ASP.NET pages?
More specifically, I'd like to use a HttpModule to initialize an instance of
a custom class, and have this class exposed directly through the HttpRequest
for the current user through a property I add to the HttpRequest object.
For example, I'd like my developers to be able to use this...
|
by: Shimon Sim |
last post by:
Hi
I am working on application that need to hold custom user information - Last
and first name, email, some other domain related information.
I used to create Base class for all my pages. The base class would have
CurrentUser property that would hold customer class in session and that was
fine for all my situations.
Now ASP.NET 2.0 came and we have Profile property for pages that could be
extended with configuration to have custom...
|
by: Marty Cruise |
last post by:
I have a custom collection which contains instances of a
custom class. With me so far?
OK, now I set the datasource of a combobox to the
collection, having overridden the ToString() function of
the custom class to return one of its text properties.
Life is good.
The first of two problems involves the combobox showing
the first item in the collection. To get around this,
| |
by: MicroMoth |
last post by:
Hi, I've got a User class which holds details of the user and is populated by
a query. I create this User object when the user successfully logs in and
then I set this object to a session variable (its for a ASP.Net site) so that
I can access any of the user's details from this session object.
The problem is when I'm trying to access a Property of the object, the
intellisence does not display the Property name. So when I type in:
...
|
by: nrasch |
last post by:
I am coding an application in VB.Net 2005 where objects of a custom class are saved/retrieved into/out of a DB. As my application moves into its 2nd version I have to add new methods and properties into my custom class.
How does one go about adding new methods and/or properties to a custom class and then updating existing objects of that class w/out breaking everything?
Ex: Pull existing object from DB -> Convert to new version of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
| |
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |