What to Expect in Visual Basic in Windows 10 | CodeGuru

What to Expect in Visual Basic in Windows 10

Introduction Exciting times are ahead, and I personally cannot wait for the new version of Visual Basic to be released. Today, I will explain a few new features in Visual Basic 14 and Windows 10. Multiline String Literals This is not my favorite feature, but it is new. You will be able to split string […]

Written By
Hannes DuPreez
Hannes DuPreez
Apr 27, 2015
2 minute read
CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More

Introduction

Exciting times are ahead, and I personally cannot wait for the new version of Visual Basic to be released. Today, I will explain a few new features in Visual Basic 14 and Windows 10.

Multiline String Literals

This is not my favorite feature, but it is new. You will be able to split string literals over multiple lines. Here is an example:

Dim strStringVariable = "Hello
Hannes!
How
are
you
today?"

Now, for a guy who has used VB since forever, I am not entirely happy with this. I still love my concatenation…

String Interpolation

Now this I love!

We, as VB developers, have been accustomed to using the placeholders expression in our strings. With String Interpolation, using an expression inside a string has become much easier. Here is an example:

'string with expressions
Dim strName = String.Format("hello {0} {1}", _
   strName, strSurname)
'string interpolation
Dim s = $"hello {strName} {strSurname}"
Advertisement

Comments Allowed in More Places

In olden days, it was impossible to add a comment inside a LINQ expression and in-Line continuations. Now, this is impossible no more because the following will be allowed:

Dim arrEmployees = {"Hannes",   'Me
      "Ella",   'My wife
      "Kay"   'My daughter
   }

'loop through employees
Dim EmployeeAdresses = From i In arrEmployees
   Let EmployeeAdress = Lookup(i)   'lookup
   Select i, EmployeeAdress

Year-first Date Literals

This finally will reduce the ambiguity between writing months first, or days first inside a date. Here is an example:

Dim dtDate1 = #2015-04-19#   ' yyyy-MM-dd, April 9th 2015
Dim dtDate2 = #2015/04/19#

‘#Region’ Directives Inside Method Bodies

Another feature that I have begged for a long time is the ability to include a Region directive inside a method. Here is how you would be able to implement it:

Function ReturnName(strName As String, _
   strSurname As String)
Try
'Method Body here
   #Region "In case of Error"
   Catch ex As Exception
'Error code here
   #End Region
End Function

The ?. Operator

Having to check for NULL values, or values that are Nothing, has always been a pain for me, and I believe many a fellow VB developer. This operator makes it easy to check for null values in objects. Here is an example of its implementation:

'Old
Dim EmpObject = Employee.Name
Dim Result = If(EmpObject IsNot Nothing, _
   Employee.Name.Surname, Nothing)
'New
Dim x = Employee.Name?.Surname
Advertisement

ReadOnly Auto-implemented Properties

You now can have ReadOnly auto-implemented properties. Here is an example of its implementation:

Class Employee
   Public ReadOnly Property Name _
      As String = ""
   Public ReadOnly Property Surname As String

   Sub New(strName As String)
      Me.Name = strName
   End Sub
End Class

Smart Name Resolution

There will be less ambiguity for some namespace methods. Sometimes, it is very irritating when you try to do something as simple as creating a thread, and then the compiler tells you that a certain method is ambiguous. With smart name resolution, the compiler will be able to automatically detect which namespace method gets called from your code.

Partial Module and Interface Declarations

VB used to allow only Partial on classes and structures. Now, it is allowed on modules and interfaces as well:

Partial Module Extensions
End Module
Partial Interface IDirectory
End Interface

Structures Allow Sub New()

VB will allow you to declare a parameterless constructor for a struct.

Structure Structure1
   Public Age As Integer
   Sub New()
      Age = 37
   End Sub
End Structure

Conclusion

These are just some of the new and exciting features to expect. For a full list, have a look here:

https://roslyn.codeplex.com/discussions/571884

Thank you for reading my article. I hope you have enjoyed it. Until we meet again, cheers!

Hannes DuPreez

Ockert J. du Preez is a passionate coder and always willing to learn. He has written hundreds of developer articles over the years detailing his programming quests and adventures. He has written the following books: Visual Studio 2019 In-Depth (BpB Publications) JavaScript for Gurus (BpB Publications) He was the Technical Editor for Professional C++, 5th Edition (Wiley) He was a Microsoft Most Valuable Professional for .NET (2008–2017).

CodeGuru Logo

CodeGuru covers topics related to Microsoft-related software development, mobile development, database management, and web application programming. In addition to tutorials and how-tos that teach programmers how to code in Microsoft-related languages and frameworks like C# and .Net, we also publish articles on software development tools, the latest in developer news, and advice for project managers. Cloud services such as Microsoft Azure and database options including SQL Server and MSSQL are also frequently covered.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.