"1)How to create TextBox_TextChanged.In form side came only single text box name (ex: TextBox1_TextChanged or TextBox2_TextChanged)."
I am not sure what you are asking there.
"2)why use DirectCast. what showing DirectCast"
If you notice, the
"sender" parameter of the TextChanged event sub is of type
Object. The TextBox that raises the event is assigned to the "sender" Object.
An Object is the base class for all .Net classes, meaning it can be assigned any class. However, an Object type does not let you directly access the specific properties and methods of the class that was assigned to it.
That is why you need to cast the
Object to a
TextBox type, so you can access the specific properties of the TextBox class that was assigned to the Object.
Using DirectCast is faster and more preferable for instances like this than using the CType operator. You can read the second post down in the link below to get an idea of the difference between DirectCast and CType.
http://stackoverflow.com/questions/3...type-in-vb-net