[AccessD] First real stumble with using VB.Net over VB

Jim Lawrence accessd at shaw.ca
Thu Apr 14 02:02:38 CDT 2011


Hi Drew:

OK...

Jim

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Drew Wutka
Sent: Wednesday, April 13, 2011 8:46 PM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] First real stumble with using VB.Net over VB

LOL, check that code again, I was retrieving a property of a field, not
the field itself...

Drew

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Jim Lawrence
Sent: Wednesday, April 13, 2011 9:06 PM
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] First real stumble with using VB.Net over VB

Hi Drew:

You can also do it this way:

Msgbox rs.fields("BASECOLUMNNAME")

Or 

Msgbox rs.fields(strFieldName)

Jim



-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Drew Wutka
Sent: Wednesday, April 13, 2011 3:22 PM
To: Access Developers discussion and problem solving
Subject: [AccessD] First real stumble with using VB.Net over VB

Figured I'd post this here, for those that may be tinkering or thinking
about tinkering with .Net.

 

In VB, one of the 'limitations' that was kind of annoying was
dynamically referring to the 'properties' of a class module.

 

For example, if I wanted the column name from a recordset, I could do
this:

 

Msgbox rs.Fields.Item(0).Name

 

But, what if I wanted to get it programmatically, .Name is hard coded:

 

Msgbox rs.Fields.Item(0).Properties("BASECOLUMNNAME")

 

That would allow me to put a variable in the properties 'property', to
retrieve a value dynamically.

 

However, with a standard class module, in VB6/VBA, the only way, I could
find, to do this, was to put in extra code into a class module to create
a 'Properties' Property.  In fact, I had written an Add-on in VB6 that
did this for me (created a properties property).  Put a LOT of extra
code into your module though.

 

In VB.Net, there is a built in capability to do this with the Reflection
Library.  So here is what I stumbled on.  I was all excited to use the
Reflection library on a particalur class where I needed to dynamically
list, set, and get properties of a class I built.....

 

The catch...

 

In VB:

 

Public SomeValue as String

-           And -

Property Get SomeValue() as string

SomeValue=strTemp

End Property

 

Both create a 'property' called SomeValue.

 

In VB.Net

Public SomeValue as String

Public Property SomeValue() as String

               Get

                               Return strTemp

                End Get

                Let (value)

                                strTemp=value

                End Let

End Property

 

In the first line, SomeValue is considered a FIELD, not a property.  The
SomeValue defined with Get/Let statements...THAT'S a PROPERTY.

 

Go figure.  Drove me nuts, couldn't figure out why I wasn't getting at
all of my properties...until I figured out that some were properties
some were "FIELDS".

 

LOL.

 

Of course, there will probably be a dozen people that already knew
that...I'm so late to the game with .Net

 

Drew


The information contained in this transmission is intended only for the
person or entity 
to which it is addressed and may contain II-VI Proprietary and/or II-VI
Business 
Sensitive material. If you are not the intended recipient, please
contact
the sender 
immediately and destroy the material in its entirety, whether electronic
or
hard copy. 
You are notified that any review, retransmission, copying, disclosure,
dissemination, 
or other use of, or taking of any action in reliance upon this
information
by persons 
or entities other than the intended recipient is prohibited.

-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com

-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com
The information contained in this transmission is intended only for the
person or entity 
to which it is addressed and may contain II-VI Proprietary and/or II-VI
Business 
Sensitive material. If you are not the intended recipient, please contact
the sender 
immediately and destroy the material in its entirety, whether electronic or
hard copy. 
You are notified that any review, retransmission, copying, disclosure,
dissemination, 
or other use of, or taking of any action in reliance upon this information
by persons 
or entities other than the intended recipient is prohibited.


-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com




More information about the AccessD mailing list