By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,760 Members | 969 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,760 IT Pros & Developers. It's quick & easy.

My.Settings object set setting by name?

P: n/a
I know there must be a way to do this... in .NET 2.0?

I have a situation where I know the name of the setting, and want to
pass it into a function, and set or get the corresponding setting.

The following is find, but a pain if you have lots of settings to do in
one go...

My.Setting.Dachshund=1000
Dim theSetting As Integer=My.Setting.Dachshund

Looking for some thing like...

Sub SetSetting(ByVal theName As String, ByVal theValue As Object)

My.Setting(theName) = theValue

End Sub

Function GetSetting(ByVal theName As String) As Object

Return (My.Settings(theName))

End Function

I figure i could call My.Setting.<Method>? Via Invoke by name? But I
am not a Invoke guru?

Any help greatly desired, Thanks

May 6 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On 2006-05-06, Dachshund Digital <Sc*******@adelphia.net> wrote:
I know there must be a way to do this... in .NET 2.0?

I have a situation where I know the name of the setting, and want to
pass it into a function, and set or get the corresponding setting.

The following is find, but a pain if you have lots of settings to do in
one go...

My.Setting.Dachshund=1000
Dim theSetting As Integer=My.Setting.Dachshund

Looking for some thing like...

Sub SetSetting(ByVal theName As String, ByVal theValue As Object)

My.Setting(theName) = theValue
This is evil, but you could always do something like

My.MySettingsProperty.Settings.Item(theName) = value
Rather than using undocumented names though, you'd probably be better
off saving a hashtable or NameValueCollection in My.Settings, then
accessing its members normally.

End Sub

Function GetSetting(ByVal theName As String) As Object

Return (My.Settings(theName))

End Function

I figure i could call My.Setting.<Method>? Via Invoke by name? But I
am not a Invoke guru?

Any help greatly desired, Thanks

May 8 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.