Here's an example using Reflection in WinForms that will work with Fields or Properties:
Public Class Form1
Private MyVar As Integer
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim thing As String = "MyVar"
Dim value As Integer = 33
Try
Dim FI As System.Reflection.FieldInfo = Me.GetType.GetField(thing, Reflection.BindingFlags.IgnoreCase Or Reflection.BindingFlags.Instance Or Reflection.BindingFlags.Public Or Reflection.BindingFlags.NonPublic)
If Not IsNothing(FI) Then
FI.SetValue(Me, value)
Else
Dim PI As System.Reflection.PropertyInfo = Me.GetType.GetProperty(thing, Reflection.BindingFlags.IgnoreCase Or Reflection.BindingFlags.Instance Or Reflection.BindingFlags.Public Or Reflection.BindingFlags.NonPublic)
If Not IsNothing(PI) Then
PI.SetValue(Me, value)
Else
MessageBox.Show(value, "Field or Property not found!")
End If
End If
Catch ex As Exception
MessageBox.Show(ex.Message, "Unable to Set Value")
End Try
Debug.Print("MyVar = " & MyVar)
End Sub
End Class
If you're using this, though, you probably have a bad design to your application.
Dictionary(Of String, Integer)in vb.net