DevAdmin Blog

Blog di Ermanno Goletto (Microsoft MVP Directory Services - MCITP - MCTS - MCSA - MCP)
posts - 886, comments - 447, trackbacks - 13

My Links

News

Avatar

Curriculum Vitae

Visualizza il profilo di Ermanno Goletto su LinkedIn


Il contenuto di questo blog e di ciascun post viene fornito “così come é”, senza garanzie, e non conferisce alcun diritto. Questo blog riporta il mio personale pensiero che non riflette necessariamente il pensiero del mio datore di lavoro.

Logo Creative Commons Deed


Logo SysAdmin.it SysAdmin.it Staff


Logo TechNet Forum TechNet Italia @ForumTechNetIt Follow TechNet Forum on Twitter


Logo MVP


Ermanno Goletto Follow ermannog on Twitter

Article Categories

Archives

Post Categories

Blogs

Friends

Knowledge Base

MVP Sites

Resources

Snippet: Ricavare il valore di una variabile in base al nome

Una delle domande che ogni tanto ricorrono nel NG di VB.NET è come ricavare il valore di una variabile conoscendo il nome. Supponendo di essere all'interno di una form ecco una soluzione al problema basata sulla Reflection:

Public Variabile As String = "Valore"

MsgBox(GetValueByName("Variabile"))

Public Function GetValueByName(ByVal name as String) As String
          Dim field As System.Reflection.FieldInfo
          field = Me.GetType.GetField(name)
          Return field.GetValue(Me).ToString()
End Function

Il metodo è estendibile comunque anche ad altri scenari.

Print | posted on Friday, April 16, 2004 5:28 PM | Filed Under [ Code, Snippets & Scripts .NET ]

Feedback

No comments posted yet.

Post Comment

Title  
Name  
Email
Url
Comment   
Please add 7 and 7 and type the answer here:

Powered by:
Powered By Subtext Powered By ASP.NET