So, I'm running into a NullReferenceException error in my code.
CreatureNumber = CreatureNumberLabel.Text
If YouOrEnemyCreatureLabel.Text = "You" Then
Person = "Your"
End If
If YouOrEnemyCreatureLabel.Text = "Enemy" Then
Person = "Enemy"
End If
'The line below is giving me the error. "_" Added for convenience.
Simulator.Controls(Person & "Creature" & CreatureNumber & "NameLabel").Text = _
CreatureNameComboBox.Text
Person and CreatureNumber have both been declared publicly, and I had to put "Simulator" in front since that's the userform that contains the control that I want to change the text of.
Now, the problem is that when I tried to recreate this issue (using 2 different userforms), it worked just how I intended it to.
Number = TextBox1.Text
Form2.Controls("Label" & Number).Text = TextBox2.Text
Again, Number was declared publicly. So why is the above code working just fine, but the first one is giving me a NullReferenceException error?