473,396 Members | 1,671 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,396 software developers and data experts.

Types, Classes: myObject("IWantThisProperty")

Hello all,

I'm using A97 and I'd like to keep about 30 informations concerning the
logged in user, in order to prevent hundreds of DB access per user to
get these informations (mainly rights + email, name, login, ...). So I
would like to load and keep these informations only once. I know I
could create an hidden form holding these values but is there another
way? I'd like to create a user-defined Type or a Classe module but I
can't figure out how to get a property value from the name of that
property (air coded):

------------------------------------------------------
Public Function getUserValue(field As String) As Variant
Static user As MyDefinedType

If IsNull(user.login) Then
'Fill the user data
End If

getUserValue = user(field) 'or user.properties(field) or ...
<-- Is there a way similar to this to access a property ?

End Function
------------------------------------------------------

I hope it's clear enough. The fact is that I really would like to keep
getUserValue(String) definition the same since this function is called
at so many place in the program.

Any other suggestion?

Yannick

Oct 18 '06 #1
3 1388
The easiest way to do this with a database application is store the details
in a table.

You can use global variables (which in effect is what you are looking at)
but you have the ever present possibility of a code crash wiping them out.

If you use a table to persist these session variables then you can easily
retrieve them and because they are persisted they will not lose their value.
--

Terry Kreft
"Yannick Turgeon" <ve********@gmail.comwrote in message
news:11**********************@k70g2000cwa.googlegr oups.com...
Hello all,

I'm using A97 and I'd like to keep about 30 informations concerning the
logged in user, in order to prevent hundreds of DB access per user to
get these informations (mainly rights + email, name, login, ...). So I
would like to load and keep these informations only once. I know I
could create an hidden form holding these values but is there another
way? I'd like to create a user-defined Type or a Classe module but I
can't figure out how to get a property value from the name of that
property (air coded):

------------------------------------------------------
Public Function getUserValue(field As String) As Variant
Static user As MyDefinedType

If IsNull(user.login) Then
'Fill the user data
End If

getUserValue = user(field) 'or user.properties(field) or ...
<-- Is there a way similar to this to access a property ?

End Function
------------------------------------------------------

I hope it's clear enough. The fact is that I really would like to keep
getUserValue(String) definition the same since this function is called
at so many place in the program.

Any other suggestion?

Yannick

Oct 19 '06 #2
MP
"Yannick Turgeon" <ve********@gmail.comwrote in message
news:11**********************@k70g2000cwa.googlegr oups.com...
Hello all,

I'm using A97 and I'd like to keep about 30 informations concerning the
logged in user, in order to prevent hundreds of DB access per user to
get these informations (mainly rights + email, name, login, ...). So I
would like to load and keep these informations only once. I know I
could create an hidden form holding these values but is there another
way? I'd like to create a user-defined Type or a Classe module but I
can't figure out how to get a property value from the name of that
property (air coded):

------------------------------------------------------
Public Function getUserValue(field As String) As Variant
Static user As MyDefinedType

If IsNull(user.login) Then
'Fill the user data
End If

getUserValue = user(field) 'or user.properties(field) or ...
<-- Is there a way similar to this to access a property ?

End Function
------------------------------------------------------
I don't know access but if it allows you to create classes similar to vb
then
Class User
Property Name
Property Login
etc
Function getUserValue(thisUser as User, thisValue as string) as variant
Select Case thisValue
Case "Name"
getUserValue = thisuser.Name
Case "Login"
getUserValue = thisuser.Login
etc
End Select
End Function
but i don't understand why you'd want this instead of calling the property
of the class directly
when you need their name you just use User.Name
instead of getUserValue(User, "Name")

when the user logs in(or whatever) create the class and populate the values
then when you need a value just access the class object directly
but I'm probably misunderstanding what you need to do....
:-)
Mark
Oct 19 '06 #3
Thanks to both of you for your ideas and suggestions.

MP a écrit :
but i don't understand why you'd want this instead of calling the property
of the class directly
when you need their name you just use User.Name
instead of getUserValue(User, "Name")
MP, that was an alternative, but the fact is that this function is
already call at hundreds of place in my code and I prefer to change the
inside of the fonction than the hundreds places. But it would be an
obviously better solution to call class properties directly.

For you information, and for posterity (!), I finally chose to use a
Collection to hold the data. Even after more than six years programming
VBA, I have to confess that I never heard about the Collection object.
But it's exactly what I needed to do this.

Thanks again for your time.

Yannick

Oct 21 '06 #4

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

Similar topics

2
by: Bob Day | last post by:
Using VS2003, VB.NET, MSDE... I am looking at a demo program that, to my surprise, has nested classes, such as the example below. I guess it surprised me becuase you cannot have nested subs,...
19
by: Dennis | last post by:
I have a public variable in a class of type color declared as follows: public mycolor as color = color.Empty I want to check to see if the user has specified a color like; if mycolor =...
14
by: pmclinn | last post by:
I've noticed that many programmers use classes to store data about such things like: Class Customers .....Phone ....ID ....Address End Class....
10
by: Chris | last post by:
Hi, I'm new to web services and I'm having some trouble figuring out how to define a custom object that works through the webservice. For example, I have the following on the server side: ...
8
by: ramu | last post by:
Hi, I want to call a vc++ function from a c program on linux. So when I do this dosen't the VC++ datatypes differ with c datatypes. Because we don't have some vc++ data types in c. I have to...
16
by: tshad | last post by:
This is a little complicated to explain but I have some web services on a machine that work great. The problem is that I have run into a situation where I need to set up my program to access one...
173
by: Zytan | last post by:
I've read the docs on this, but one thing was left unclear. It seems as though a Module does not have to be fully qualified. Is this the case? I have source that apparently shows this. Are...
3
by: jacques | last post by:
Hi all, I've written a load of classes which inherit from another base class which I've written. Is it possible to enumerate all the classes which inherit from a particular base class? I'd like...
29
by: Dom | last post by:
I'm really confused by the difference between a Struct and a Class? Sometimes, I want just a group of fields to go together. A Class without methods seems wrong, in that it carries too much...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
agi2029
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,...

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.