Private ReadOnly valuesByKey As New Dictionary(Of String, String) Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click valuesByKey.Add(keyTextBox.Text, valueTextBox.Text) End Sub
You're not talking about variables. If you want to use String values provided by the user at run time then you would use a Dictionary where the keys are Strings. Let's say that you have two TextBoxes on your form: one for the key and one for the value. Your code might look like this:Private ReadOnly valuesByKey As New Dictionary(Of String, String) Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click valuesByKey.Add(keyTextBox.Text, valueTextBox.Text) End Sub
TextBox.Text = "abc"
Dim TextBox.Text as string
Public Module VariableContainer
Public Const obj As String = "This is the value for variable obj, in the VariableContainer class..."
End Module
Dim obj As FieldInfo = Assembly.GetExecutingAssembly().GetTypes().First(Function(T) T.Name.Contains("VariableContainer")).GetFields().FirstOrDefault(Function(FI) FI.Name = TextBox1.Text)
If obj IsNot Nothing Then
MessageBox.Show(obj.GetValue(Nothing).ToString)
End If