How to pass System.Type

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'd like to pass a System.Type object to a sub.
The following works:

Public Sub main()
Dim connType As System.Type, obj As Object
obj = New System.Data.OleDb.OleDbConnection
connType = obj.GetType
foo(connType)
End Sub

Public Sub foo(ByVal connType As System.Type)
Dim t As System.Type, obj As Object
obj = New System.Data.OleDb.OleDbConnection
t = obj.GetType
If connType.Equals(t) Then
MessageBox.Show(connType.FullName & " type was passed.")
End If
End Sub

I'd like to change this so that:
- no objects are instantiated
- the code is concise

Thanks in advance for your help,
Hal Heinrich
VP Technology
Aralan Solutions Inc.
 
foo(GetType(System.Data.OleDb.OleDbConnection))

....

If connType Is GetType(System.Data.OleDb.OleDbConnection) Then




Mattias
 
Back
Top