Rather than have a collection of functions to process data based on the control type that is passed to it, im wondering if its at all possible to convert an object to a specific control so that i can initial a Dim as the control type? Might be better for an example.. Lets say i have a range of controls that will all require the use of a function, these controls will be-
TextBox, Label, ComboBox, DataGrid, ListBox.
Each control type shares some common properties but not all. Here is an example of that id like to construct, its obviously not valid because its what im trying to achieve-
Function ProcessData(ByVal _control As Control) As String Dim _C as Control = Nothing Select Case _control.GetType() Case GetType(TextBox) _C = CType(_control, TextBox) Case GetType(Label) _C = CType(_control, Label) Case GetType(ComboBox) _C = Ctype(_control.ComboBox) Return _C.Text End Function
So the result i am after is no matter what control is passed to the function, i can assign the controls type to _C so that i can access the control Type properties relative to the Control being passed. If a TextBox is passed then _C As TextBox, if a ComboBox is passed then _C As ComboBox etc etc.
Is this achievable?