VB.NET Function Return

The difference is that they DO DIFFERENT THINGS! ‘Return value’ does 2 things: 1. It sets the function return value at that point 2. It immediately exits the function No further code in the function executes! ‘Functionname = value’ does 1 thing: 1. It sets the function return value at that point Other code in … Read more

VB.NET What is the purpose of a class or module?

A module is really very similar to just a class containing only shared members. In fact, in C#, there is no such construct as a “module”. You cannot write any application without having at least one module or class, so I suspect your real question is not “why use classes and modules”, but rather “why … Read more

ByVal and ByRef with reference type

Since you declared TypeTest as a Class, that makes it a reference type (as opposed to Structure which is used to declare value types). Reference-type variables act as pointers to objects whereas value-type variables store the object data directly. You are correct in your understanding that ByRef allows you to change the value of the … Read more

Convert a string to a datetime

You should have to use Date.ParseExact or Date.TryParseExact with correct format string. Dim edate = “10/12/2009” Dim expenddt As Date = Date.ParseExact(edate, “dd/MM/yyyy”, System.Globalization.DateTimeFormatInfo.InvariantInfo) OR Dim format() = {“dd/MM/yyyy”, “d/M/yyyy”, “dd-MM-yyyy”} Dim expenddt As Date = Date.ParseExact(edate, format, System.Globalization.DateTimeFormatInfo.InvariantInfo, Globalization.DateTimeStyles.None) OR Dim format() = {“dd/MM/yyyy”, “d/M/yyyy”, “dd-MM-yyyy”} Dim expenddt As Date Date.TryParseExact(edate, format, System.Globalization.DateTimeFormatInfo.InvariantInfo, Globalization.DateTimeStyles.None, … Read more

What is the use of a shared variable in VB.NET?

It is the same as static in C# and most other languages. It means that every object in the class uses the same copy of the variable, property or method. When used with a method as it is static you don’t need an object instance. MyClass.DoSomething() rather than Dim oObject as New MyClass() oObject.DoSomething()