Writing a Public Class Function to set variables dynamically
Messages   Related Types
This message was discovered on ASPFriends.com 'aspngvb' list.


Thomas Fuller
All,

I've been trying to figure out a way to set my class variables dynamically
as I loop through a set of variables that vary for each user I return.
Essentially I want to do what Javascript allows you to do with the eval()
function but can't seem to find it's equivalent in VB.Net. However, my
other thought was that I could set the variable by passing the variable name
and the variable value and setting it with a public method in the class.
Here's an example of what I'm trying to do:

Dim USER_PROPS As New ADSUSER_PROPERTIES()
USER_PROPS.setProperty("displayname", "THOMAS FULLER")

Public Class ADSUSER_PROPERTIES

Public displayname As String

Public Sub setProperty(ByVal propName As String, ByVal propValue As
String)
propName = propValue
End Sub

End Class

This code does not work can anyone see what I'm doing wrong?

Thanks All,

Tom Fuller
Reply to this message...
 
    
Patrick Steele
All,
=20
I've been trying to figure out a way to set my class variables
dynamically
as I loop through a set of variables that vary for each user I return.
Essentially I want to do what Javascript allows you to do with the
eval()
function but can't seem to find it's equivalent in VB.Net. However, my
other thought was that I could set the variable by passing the variable
name
and the variable value and setting it with a public method in the class.
Here's an example of what I'm trying to do:
=20
=20
Dim USER_PROPS As New ADSUSER_PROPERTIES()
USER_PROPS.setProperty("displayname", "THOMAS FULLER")
=20
Public Class ADSUSER_PROPERTIES
=20
Public displayname As String
=20
Public Sub setProperty(ByVal propName As String, ByVal propValue As
String)
propName =3D propValue
End Sub
=20
End Class
=20
=20
This code does not work can anyone see what I'm doing wrong?
Reply to this message...
 
    
Darren Neimke
All,
=20
I've been trying to figure out a way to set my class variables
dynamically as I loop through a set of variables that vary for each user
I return. Essentially I want to do what Javascript allows you to do with
the eval() function but can't seem to find it's equivalent in VB.Net.
However, my other thought was that I could set the variable by passing
the variable name and the variable value and setting it with a public
method in the class. Here's an example of what I'm trying to do:
=20
=20
Dim USER_PROPS As New ADSUSER_PROPERTIES()
USER_PROPS.setProperty("displayname", "THOMAS FULLER")
=20
Public Class ADSUSER_PROPERTIES
=20
Public displayname As String
=20
Public Sub setProperty(ByVal propName As String, ByVal propValue As
String)
propName =3D propValue
End Sub
=20
End Class
=20
=20
This code does not work can anyone see what I'm doing wrong?
=20
Thanks All,
=20
Tom Fuller
Reply to this message...
 
 




Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
 
 Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us - Terms of Use - Privacy Policy - www.dotnet247.com