Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I tried your situation on a Windows Forms application (.NET 4) and the following worked. I'm not sure why your way of using <code>GetType(T1) Is GetType(T2)</code> isn't working (maybe it has different semantics, like it doesn't consider inheritance) but you can use this instead:</p> <pre><code>Sub Show1() For Each ctrl As Control In Controls If TypeOf ctrl Is UserControl Then ctrl.Hide() End If Next UserControl11.Show() End Sub </code></pre> <p><strong>Update:</strong></p> <p>I checked the MSDN to see why is your code not working. Firstly the <code>TypeOf .. Is</code> operator is the one used to check for whether a type of an object is compatible with another. Here's what they MSDN article at (Link: <a href="http://msdn.microsoft.com/en-us/library/e5kz7s8h%28v=vs.71%29.aspx" rel="nofollow">TypeOf keyword</a>) says:</p> <blockquote> <p>The TypeOf keyword introduces a comparison clause that tests whether an object is derived from or implements a particular type, such as an interface.</p> </blockquote> <p>However you're using the Is keyword (very different from that used in C# to check whether an object is of some particular type). The "Is" keyword is used to check whether two references reference the same object. Here's what MSDN at (Link: <a href="http://msdn.microsoft.com/en-us/library/kb136x1y%28v=vs.71%29.aspx" rel="nofollow">Is keyword</a>) says:</p> <blockquote> <p>[Is] Compares two object reference variables.</p> </blockquote> <p>So I was right: you're using an operator with different semantics than your intentions. I rarely write VB .NET code these days. Nice question.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload