I have a label named lblMessage, which is the only label by that name in my app.
I did not know that labels can be made into an array or collection with different indexes (indices), and the properties of the label view does not show index as a property.
The code line with the error is:
Code line:
lblMessage.Text = "Enter the registration code"
The error I Get is:
Index was out of range. Must be non negative and less than the size of the collection. Parameter name: Index
When I completed the 'if .. end if' construct , this error disappeared.
I do not why it gave it. It has nothing to do with the construct.
I take note of the two good tips by JohnC and DonManfred.