title: How to use the Type class as type in variable declaration
body: <p>I want to make the same operations on different lists of controls of specific types. I could do it one type at a time, but I figured: &quot;There's a bunch of these, so why not do this in a loop?&quot; and now of course I'm wondering where I went wrong. The problem can be reproduced easily:</p>
  <pre><code>Dim myType As Type = GetType(TextBox)
  Dim newList As New List(Of myType) ' this is not allowed
  </code></pre>
  <p>This is the specific error message: BC30002: Type 'currentType' is not defined</p>
  <p><a href="https://i.stack.imgur.com/WielI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WielI.png" alt="error message" /></a></p>
  <p>Is there a way to use an object of the Type class as a type, or to do a similar maneuver which would let me do something like this:</p>
  <pre><code>For Each currentType As Type In {GetType(myCustomType), GetType(anotherCustomClassType)}
      Dim newList As New List(Of currentType)
      ' do stuff
  Next
  </code></pre>