Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB.NET 1.0 > VB.NET 2002/2003 Basics
|
VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET 2002/2003 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 10th, 2004, 10:14 AM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 142
Thanks: 0
Thanked 2 Times in 2 Posts
Default Property/Method access using string values

Is there a way to access properties/methods of an object using string values? For example, to access the Person.Fullname property would it be possible to do the following...

Public Sub MySub()
  ' get fullname...
  Dim name As String = GetProperty(myPerson, "Fullname")
End Sub

Public Function GetProperty(ByVal nObject As Object, _
  ByVal property As String) As Object
Return nObject.property
End Function

The bit I don't know how to do is the 'Return nObject.property', or even if it is possible. Is it?

Thanks in advance

 
Old February 10th, 2004, 01:05 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Perhaps the System.Reflection.Binder class will have provide what you need. Though IMHO performing this kind of task sort of defeats the purpose of the nice strongly typed properties that the class provides.

Peter
------------------------------------------------------
Work smarter, not harder.





Similar Threads
Thread Thread Starter Forum Replies Last Post
OBJECT DOESNT SUPPORT THIS PROPERTY OR METHOD KGANESH2006 Classic ASP Basics 4 March 24th, 2006 11:15 AM
Object doesn't support this property or method ASP crmpicco Classic ASP Components 0 March 16th, 2006 01:26 PM
Get all property values of class rrhandle ASP.NET 1.0 and 1.1 Basics 1 January 12th, 2006 05:13 PM
Setting ReadOnly Property Values Gavin265 General .NET 8 May 19th, 2005 12:49 PM





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