I encountered an error. Despite declaring the variables (failturetext and userName) errors still appear. Can anyone please help me?
- Use of Unassigned local va
If you wish to keep the same convention as you have at the moment, then to solve the issue of it failing compilation you want to assign the two variables a null value first before you try to reference them.
Like so:
TextBox FailureText = null;
TextBox UserName = null;
If you do this, you might need to check on whether they are still null when you try and assign the properties of these objects.
As people above have stated, you should not be doing it this way as UI controls should always be global to the form itself.