How to pass System.Type

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.
 
M

Mattias Sjögren

foo(GetType(System.Data.OleDb.OleDbConnection))

....

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




Mattias
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top