user3738636 user3738636 - 1 year ago 62 Question

Get Length of Control.Tag

I am trying to find the length of a control's tag to determine a Boolean's value. I've tried a couple methods to get the text length of a Tag in a control and determine if it has a length of 1 or higher, but none of them seem to be working. They all end up with a


Boolean = Control.Tag.ToString.Length > 1
Boolean = Control.Tag.ToString.Count > 1
Boolean = Not Control.Tag.Equals("")
Boolean = Not Control.Tag.ToString.Equals("")


Thats because your Tag is Null (or as it's called in VB Nothing). So before you check the length of the Tag, you need to make sure it's not Nothing. e.g with:

If Control.Tag Is Nothing Then ...