As peterG mentioned, CallByName() can be used. This however requires that the var1 variable be declared as Public at Class(Form) level:
Public Class Form1
Public var1 As String = "test1"
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim newvar As String = "var1"
Dim othervar As String = CallByName(Me, newvar, CallType.Get)
MessageBox.Show(othervar)
End Sub
End Class
If var1 is Private then you can use Reflection like this (it still must be a Class level variable):
Imports System.Reflection
Public Class Form1
Private var1 As String = "test1"
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim newvar As String = "var1"
Dim FI As FieldInfo = Me.GetType.GetField(newvar, BindingFlags.Instance Or BindingFlags.Public Or BindingFlags.NonPublic)
Dim othervar As String = FI.GetValue(Me)
MessageBox.Show(othervar)
End Sub
End Class
Note that if var1 is a local variable then no method exists to retrieve its value.
var1is declared. Is it a local variable in a method (with the other two variables)?...or is it declared at class/form level?var1is declared as Public in a Class. If that is not the case then you'd have to use Reflection to accomplish the task.