I am trying to clean my ways as a beginner programmer by using Option Strict On. I managed to clean all errors except this one.
I am using the Tag property of a ToolStrip for some text information. Clicking on the ToolStrip, I need to remember the value of the Tag in a string and change the value of that Tag.
How can I convert the Object {String} sender.tag to a String and the String myString and an Object {String}?
Private Sub ToolStrip_ItemClicked(sender As Object, e As ToolStripItemClickedEventArgs) Handles ToolStrip.ItemClicked
Dim myString As String = sender.tag
sender.tag = "It is selected"
'more code...
End Sub
Edit: see here a screenshot of the relevant part of the code:

Good that you have titled your question generically. And you need a generic answer.
Option Strict Onis a good thing. It makes harder to code but performance at runtime will increase because there will be less implicit data type conversions.Lets take your code
...sender As Object...and...sender.tag..This is a typical thing in .net. Often you see a parameter of typeobject, which means, any data type can be passed. Object does not have all the properties and methods defined that belong to that data type.For example
oTxtwill not automatically have propertyText. You need tocast. When you know 100% the object type, doBut sometimes you don't know what
Typeis in yourobject. In this case you try casting and then check fornullYour real problem is that you need to understand type casting. You should cast it explicitly even if you don't have
Options Strinct Onbecause when you dox = sender.tagimplicitly, you really using a late binding, which is bad for performance. And this also opens doors for potential runtime errors.Your topics of research should be: type casting, late binding, boxing/unboxing