Is VB really case insensitive?

The difference between VBA and VB.NET is just because VB.NET compiles continuously in the background. You’ll get an error when you compile the VBA. Like Jonathan says, when programming you can think of VB.NET as case-insensitive apart from string-comparisons, XML, and a few other situations… I think you’re interested in what’s under the hood. Well, … Read more

How does inheritance work for Attributes?

When Inherited = true (which is the default) it means that the attribute you are creating can be inherited by sub-classes of the class decorated by the attribute. So – if you create MyUberAttribute with [AttributeUsage (Inherited = true)] [AttributeUsage (Inherited = True)] MyUberAttribute : Attribute { string _SpecialName; public string SpecialName { get { … Read more

Custom Compiler Warnings

This is worth a try. You can’t extend Obsolete, because it’s final, but maybe you can create your own attribute, and mark that class as obsolete like this: [Obsolete(“Should be refactored”)] public class MustRefactor: System.Attribute{} Then when you mark your methods with the “MustRefactor” attribute, the compile warnings will show. It generates a compile time … Read more

IsNothing versus Is Nothing

If you take a look at the MSIL as it’s being executed you’ll see that it doesn’t compile down to the exact same code. When you use IsNothing() it actually makes a call to that method as opposed to just evaluating the expression. The reason I would tend to lean towards using “Is Nothing” is … Read more

Measuring code execution time

A better way would be to use Stopwatch, instead of DateTime differences. Stopwatch Class – Microsoft Docs Provides a set of methods and properties that you can use to accurately measure elapsed time. // create and start a Stopwatch instance Stopwatch stopwatch = Stopwatch.StartNew(); // replace with your sample code: System.Threading.Thread.Sleep(500); stopwatch.Stop(); Console.WriteLine(stopwatch.ElapsedMilliseconds);

How to get ALL child controls of a Windows Forms form of a specific type (Button/Textbox)?

Here’s another option for you. I tested it by creating a sample application, I then put a GroupBox and a GroupBox inside the initial GroupBox. Inside the nested GroupBox I put 3 TextBox controls and a button. This is the code I used (even includes the recursion you were looking for) public IEnumerable<Control> GetAll(Control control,Type … Read more