From the course: Visual Basic Essential Training

The forgiving nature of VB code - Visual Basic Tutorial

From the course: Visual Basic Essential Training

Start my 1-month free trial

The forgiving nature of VB code

- Visual Basic is designed to be easy to read and easy to learn. The VB Compiler will do its best to compile your code and will overlook many issues that stop other compilers. Here's a few examples. Visual Basic is case insensitive, which means the compiler ignores case when compiling the code. By convention .NET uses Pascal case for method names and class names. Here's an example of Pascal case. "ForegroundColor". Each word in this property is capitalized. Capital "F" and capital "C". Same here with "ConsoleColor". That's the name of this type or "DayofWeek". Those are capitalized "Day" "of" and "Week". I don't know if you noticed this earlier when I created my code is I forgot to capitalize the "L" in "Rightline". If this was a C# application and I tried to compile this line of code it would fail, but VB compiles it anyway. Now let's look at some extreme examples. I've made a copy of my code and I've called this one "FirstAppLowerCase" and "FirstAppUpperCase". So this is all lowercase words. (keyboard strokes) This is all uppercase words, and then I can go over here to the command line and compile those. (keyboard strokes) You see that they compile successfully. VB ignores the case and the applications run exactly the same. Here's what they look like. There's the lowercase one compiled, here's the uppercase one. Another place where you can see the forgiveness of Visual Basic is for things like this method call. On many languages when you make a method call you have to do the parameters with parentheses. So I should have written the code like this. But the VB Compiler knows that this is a method with no parameters so it's really not necessary to have the parentheses here so it went ahead and compiled the code anyway. Frankly, this is one of the benefits that attracted me to Visual Basic many years ago. At this point we have our first rudimentary application. You've seen some of the principles of .NET and Visual Basic. It's time to work with more helpful tools however. Lets move to Visual Studio and write our code there.

Contents