I'm new to vb.net and still have lots to learn. This works, but I'm sure there's an easier way to do it. Could someone point me in the right direction? Thanks.

```
Public Function GetValue(passVal As Object, valType As Type, errorVal As Object) As Object
    Try
        Select Case valType
            Case GetType(String)
                Return CType(passVal, String)
            Case GetType(Date)
                Return CType(passVal, Date)
            Case GetType(Decimal)
                Return CType(passVal, Decimal)
            Case GetType(Integer)
                Return CType(passVal, Integer)
            Case GetType(Boolean)
                Return CType(passVal, Boolean)
            Case Else
                MsgBox("Type Not Recognized")
                Return errorVal
        End Select
    Catch ex As Exception
        Return errorVal
    End Try
End Function

```