{"id":7855,"date":"2017-03-30T21:13:14","date_gmt":"2017-03-31T05:13:14","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/vbteam\/?p=7855"},"modified":"2024-07-05T12:36:47","modified_gmt":"2024-07-05T19:36:47","slug":"whats-new-in-visual-basic-2017","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/vbteam\/whats-new-in-visual-basic-2017\/","title":{"rendered":"What&#039;s New in Visual Basic 2017"},"content":{"rendered":"<p><a href=\"https:\/\/www.visualstudio.com\/downloads\">Visual Studio 2017<\/a> just shipped, and with it shipped a new version of Visual Basic. With the new language strategy of the .NET Languages, the focus is again on Visual Basic\u2019s original virtue: Provide editor, debugging and refactoring tools as well as language feature to ease complex tasks and boost every VB\u2019s developer productivity without distracting them from their domain specific excellence. After all, it always was first Visual Basic which put the \u2018Visual\u2019 into Visual Studio, and let developers get the work done efficiently, yet without compromises in quality! \ud83d\ude0e<\/p>\n<h2>Speed up Solution Loading times with <i>Enable Lightweight Solution Load<\/i><\/h2>\n<p>One of the most important changes in Visual Studio 2017 is improved performance. In many areas, Visual Studio 2017 got considerable faster than Visual Studio 2015. In one discipline, however, you can speed up waiting time for your really big Visual Basic solutions a lot: You just need to <i>Enable Lightweight Solution Load<\/i>. <\/p>\n<p><a href=\"http:\/\/devblogs.microsoft.com\/vbteam\/wp-content\/uploads\/sites\/7\/2017\/03\/08LightweightSolutions.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/vbteam\/wp-content\/uploads\/sites\/7\/2017\/03\/08LightweightSolutions-1.png\" alt=\"Lightweight Solutions\" width=\"535\" height=\"493\" class=\"alignnone size-full wp-image-7857\" \/><\/a><\/p>\n<p>To this end,<\/p>\n<ul>\n<li>Open your large solution as you always do.<\/li>\n<li>From the Context menu of the solution in the solution explorer, click <i>Enable Lightweight Solution Load<\/i>.<\/li>\n<li>Restart Visual Studio, and reload your Solution to observe the differences in load time.<\/li>\n<\/ul>\n<p>After a few seconds of preparation time, the solution loads and is there almost instantly. Notice though, when you do this for the first time, all the branches of the solution explorer tree view are closed. Visual Studio remembers also for solutions with lightweight loading, which branches were open when you closed the solution, and reopens them on next load. Keep in mind though, that projects get loaded, when their correlated branch is open \u2013 so the more branches you had open when you quit Visual Studio, the longer it takes to reload your solution on next start.<\/p>\n<h2>New IDE Features<\/h2>\n<p>As a Visual Basic developer, you attach importance to a productive IDE, which helps you focus on and speed up your daily VB development tasks. Visual Studio 2017 introduces a great deal of new features around IntelliSense, refactoring and navigation to that end.<\/p>\n<h3>Structure Guide Lines<\/h3>\n<p>One of the most obvious new aids you\u2019ll notice after you started Visual Studio for the first time, are <i>Structure Guide Lines<\/i>. When you\u2019re editing extensive methods, which are more than a screen page long, Structure Guide Lines help you to keep track of the structure indent level you\u2019re currently seeing and editing. Just hover with the mouse over a guideline and let the editor give you an overview over the current structure levels. <\/p>\n<p><a href=\"http:\/\/devblogs.microsoft.com\/vbteam\/wp-content\/uploads\/sites\/7\/2017\/03\/01StructureGuidelines.gif\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/vbteam\/wp-content\/uploads\/sites\/7\/2017\/03\/01StructureGuidelines-1.gif\" alt=\"01structureguidelines\" width=\"800\" height=\"360\" class=\"alignnone size-full wp-image-7865\" \/><\/a><\/p>\n<h3>IntelliSense filtering<\/h3>\n<p>Since Visual Basic 5.0, IntelliSense has always been a great source for finding and exploring types or all a type\u2019s members. Visual Studio 2017 lets types become even more quickly discoverable by introducing IntelliSense filtering and highlighting. Imagine, for example, you wanted to find all the Async methods which a type provides, since you\u2019re refactoring an app to become more responsive:<\/p>\n<p><a href=\"http:\/\/devblogs.microsoft.com\/vbteam\/wp-content\/uploads\/sites\/7\/2017\/03\/02IntelliSenseFilteringHighlighting.gif\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/vbteam\/wp-content\/uploads\/sites\/7\/2017\/03\/02IntelliSenseFilteringHighlighting-1.gif\" alt=\"02intellisensefilteringhighlighting\" width=\"550\" height=\"396\" class=\"alignnone size-full wp-image-7875\" \/><\/a><\/p>\n<p>Press Space to open IntelliSense. At the bottom of the list you\u2019ll find filter icons, each of which allowing you to limit the IntelliSense list to properties, methods, local variables, and much more. Click on an icon to add the filter category to the result list. Click another time to hide the category from the list. Continue typing to filter the list to the characters you already typed in \u2013 those characters get highlighted in the result list. You do not need the mouse to filter the IntelliSense list: When you hover over the filter icons, Visual Studio shows you the keyboard short cuts for the different categories for filtering the list without the mouse.<\/p>\n<h3>Configure IntelliSense<\/h3>\n<p>Apart from the Visual Basic IntelliSense standard settings, Visual Studio allows you to configure IntelliSense for usage in the Visual Basic code editor. To this end, from the <i>Tools<\/i> pulldown menu, pick <i>Options<\/i>, and in the <i>Search box<\/i> type in \u2018IntelliSense\u2019. Click on the entry <i>IntelliSense<\/i> under <i>Text Editor\/Basic<\/i>.<\/p>\n<p><a href=\"http:\/\/devblogs.microsoft.com\/vbteam\/wp-content\/uploads\/sites\/7\/2017\/03\/05ConfigureIntelliSense.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/vbteam\/wp-content\/uploads\/sites\/7\/2017\/03\/05ConfigureIntelliSense-1.png\" alt=\"05configureintellisense\" width=\"865\" height=\"591\" class=\"alignnone size-full wp-image-7885\" \/><\/a><\/p>\n<h3>Code Suggestions<\/h3>\n<p>The Visual Studio IDE helps you constantly improve your Visual Basic code. If your open a Visual Basic code file, look out for four gray dots in your code:<\/p>\n<p><a href=\"http:\/\/devblogs.microsoft.com\/vbteam\/wp-content\/uploads\/sites\/7\/2017\/03\/06CodeSuggestions.gif\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/vbteam\/wp-content\/uploads\/sites\/7\/2017\/03\/06CodeSuggestions.gif\" alt=\"06codesuggestions\" width=\"1106\" height=\"346\" class=\"alignnone size-full wp-image-7895\" \/><\/a><\/p>\n<p>Move the cursor to the line. The Lightbulb shows up. Now either press Ctrl+. or Alt + Enter on the keyboard \u2013 alternatively hover the mouse over the Lightbulb, and open <i>Quick Actions<\/i> by clicking. Pick one of the offered code suggestions (e.g. <i>Fix Name Violation: MoveButton_Click<\/i>) from the menu, or <i>Suppress <\/i>the suggestion. If you want to suppress a code suggestion, you can do this for just this spot by letting Quick Actions surround the code line with a correlating <i>#Disable Warning<\/i> directive. If you don\u2019t like to annotate your code with those directives, because you think too many of them are making the code hard to read, Quick Actions can also create or maintain a suppression file for the current project for you, in which all suppression spots are collected.<\/p>\n<h3>Configure Code Styles and Code Suggestions<\/h3>\n<p>If you want to configure coding style rules (and the resulting code suggestions) on a more global scale, Visual Studio 2017 offers you to configure rules to this end in two ways: Use the configuration dialog for Code Styles, which you can display by picking <i>Options<\/i> from the <i>Tools<\/i> pulldown menu. In the tree view, find the category <i>Text Editor<\/i>, <i>Basic<\/i>, <i>Code Style<\/i>.<\/p>\n<p><a href=\"http:\/\/devblogs.microsoft.com\/vbteam\/wp-content\/uploads\/sites\/7\/2017\/03\/07ConfigureCodeStyle.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/vbteam\/wp-content\/uploads\/sites\/7\/2017\/03\/07ConfigureCodeStyle-1024x828-1.png\" alt=\"07configurecodestyle\" width=\"879\" height=\"711\" class=\"alignnone size-large wp-image-7905\" \/><\/a><\/p>\n<h3>Use .editorconfig files<\/h3>\n<p>When you work on bigger solutions in a team, you need to configure your code style in a different way, because changes to the configuration need to affect the Editor\u2019s behavior for that project of every team member. To this end, you can include <i>.editorconfig<\/i> files which hold the code style settings either for the whole solution (you would need to put this file in a Solution folder) or a single project.<\/p>\n<p>Kasey Uhlenhuth from the Visual Studio Team explains <i>.editorconfig<\/i> files <a href=\"https:\/\/blogs.msdn.microsoft.com\/dotnet\/2016\/12\/15\/code-style-configuration-in-the-vs2017-rc-update\/\">here in more detail<\/a>.<\/p>\n<h2>New Debugging Aids<\/h2>\n<p>Visual Studio 2017 got a couple of new debugging aids for Visual Basic Developers. First: The exception helper dialog has been modernized and is now much easier to handle. And there is more!<\/p>\n<h3>New Exception Helper<\/h3>\n<p>The new Exception Helper is a great improvement, when you examine Exceptions during a Visual Basic debug session. One of the most helpful new features of this new Exception Helper is how it can assist you to find out, which part of an expression actually caused a <i>NullReferenceException<\/i>. The Exception Helper shows you the exact spot within the expression where the <i>NullReferenceException<\/i> occurred.<\/p>\n<p><a href=\"http:\/\/devblogs.microsoft.com\/vbteam\/wp-content\/uploads\/sites\/7\/2017\/03\/13NullReferenceExceptionHelper.png\"><img decoding=\"async\" src=\"\" alt=\"13nullreferenceexceptionhelper\" width=\"500\" height=\"281\" class=\"alignnone size-mediumlarge wp-image-7915\" \/><\/a><\/p>\n<p>There are some limitations though: This does not work when you\u2019re debugging JIT-optimized code (which results for example when you compile with the default <i>Release<\/i> setting), when expressions involve boxing\/unboxing (<i>ValueType<\/i> via <i>DirectCast<\/i> or <i>CType<\/i> from <i>Object<\/i>), when <i>Nullable <\/i>types are involved or when you involve array references.<\/p>\n<p>In addition, the exception helper is no longer a modal dialog like the Exception Assistant has been, so it is much easier to handle when you debug your application. And on top, if you open the exception details, you can evaluate the exception right in that dialog, and even add the exception expression to the current Watch tool window.<\/p>\n<h3>Run execution to here<\/h3>\n<p>Assume, you need to debug a very extensive method step-by-step. Of course, the first thing you do is setting breakpoints at those spots where you suspect bugs or faulty code to be. And now the challenge begins: While you are debugging the code, you need to skip over code parts, which are really time-consuming to debug step-by-step \u2013 like loops. What you had to do until now is setting temporary breakpoints at those spots, at which you wanted to continue debugging, then continue program execution (F5), and when the debugger hit such a temporary breakpoint, you would immediately delete it and continue debugging step-by-step. Or, you needed to set the cursor in that line, and from the menu or with a shortcut use the Debug Function <i>Run to Cursor.<\/i> In Visual Basic 2017 things got much easier, and you do not need to do that anymore \u2013 you can just use the <i>Run to Click<\/i> experience with the function <i>Run execution to here<\/i>: When you are debugging, in front of each line, you\u2019ll find a little arrow. Click on it, and the debugger runs the app until it reaches that line \u2013 where it automatically breaks. If that line isn\u2019t reached, the program runs to the end.<\/p>\n<p><a href=\"http:\/\/devblogs.microsoft.com\/vbteam\/wp-content\/uploads\/sites\/7\/2017\/03\/10RunExecutionToHere.gif\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/vbteam\/wp-content\/uploads\/sites\/7\/2017\/03\/10RunExecutionToHere.gif\" alt=\"10runexecutiontohere\" width=\"1074\" height=\"385\" class=\"alignnone size-full wp-image-7916\" \/><\/a><\/p>\n<h2>New Refactorings for VB<\/h2>\n<p>Visual Basic 2017 got some cool new Refactoring tools. Visual Basic 2010 already introduced the refactoring tool category <i>Generate from Usage<\/i> which helped you to use Classes, Interfaces, Properties and other Elements first, and let the IDE then generate the Code for those items you already used. <\/p>\n<p>As an example, insert a line of code in a method using a class, which does not yet exist (make sure to start the class name with a capital letter, because otherwise the IDE won\u2019t show the code generation options):<\/p>\n<p><a href=\"http:\/\/devblogs.microsoft.com\/vbteam\/wp-content\/uploads\/sites\/7\/2017\/03\/14CreateType.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/vbteam\/wp-content\/uploads\/sites\/7\/2017\/03\/14CreateType.png\" alt=\"14createtype\" width=\"1075\" height=\"234\" class=\"alignnone size-full wp-image-7925\" srcset=\"https:\/\/devblogs.microsoft.com\/vbteam\/wp-content\/uploads\/sites\/7\/2017\/03\/14CreateType.png 1075w, https:\/\/devblogs.microsoft.com\/vbteam\/wp-content\/uploads\/sites\/7\/2017\/03\/14CreateType-300x65.png 300w, https:\/\/devblogs.microsoft.com\/vbteam\/wp-content\/uploads\/sites\/7\/2017\/03\/14CreateType-768x167.png 768w, https:\/\/devblogs.microsoft.com\/vbteam\/wp-content\/uploads\/sites\/7\/2017\/03\/14CreateType-1024x223.png 1024w\" sizes=\"(max-width: 1075px) 100vw, 1075px\" \/><\/a><\/p>\n<p>With Quick Actions, Visual Studio 2015 gave you already a bunch of options to create a new type.<\/p>\n<p>Visual Basic 2017 lets you in addition\u2026<\/p>\n<h3>Move Type to matching File<\/h3>\n<p>\u2026 move a type, which is defined along with other Classes or Structures in the same code file, automatically to its own code file with the corresponding filename.<\/p>\n<p><a href=\"http:\/\/devblogs.microsoft.com\/vbteam\/wp-content\/uploads\/sites\/7\/2017\/03\/04MoveTypeToFile.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/vbteam\/wp-content\/uploads\/sites\/7\/2017\/03\/04MoveTypeToFile-1.png\" alt=\"04movetypetofile\" width=\"895\" height=\"693\" class=\"alignnone size-full wp-image-7935\" \/><\/a><\/p>\n<h3>Sync type and Filename<\/h3>\n<p>If you already have a separate code file for a Class, an Enum or a Module, but the filename ended up to be different from the element\u2019s name in the code, with Visual Studio 2017 it\u2019s just one click to sync both names: <\/p>\n<p><a href=\"http:\/\/devblogs.microsoft.com\/vbteam\/wp-content\/uploads\/sites\/7\/2017\/03\/11SyncFile.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/vbteam\/wp-content\/uploads\/sites\/7\/2017\/03\/11SyncFile-1.png\" alt=\"11syncfile\" width=\"829\" height=\"255\" class=\"alignnone size-full wp-image-7945\" \/><\/a><\/p>\n<h2>Find all references<\/h2>\n<p>Previous versions of Visual Studio already introduced <i>Find all References<\/i>, so you could get a quick glance of where in your solution you used a certain class, method, property or other type items. To find a reference of an item, just click on that element in the code file, open the context menu and klick <i>Find all References<\/i>. In contrast to previous versions, the result list in Visual Studio 2017 is now much more useful and clearly arranged. Try it out:<\/p>\n<p><a href=\"http:\/\/devblogs.microsoft.com\/vbteam\/wp-content\/uploads\/sites\/7\/2017\/03\/09FindAllReferences.gif\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/vbteam\/wp-content\/uploads\/sites\/7\/2017\/03\/09FindAllReferences-1.gif\" alt=\"09findallreferences\" width=\"829\" height=\"680\" class=\"alignnone size-full wp-image-7955\" \/><\/a><\/p>\n<h2>New VB Language Features<\/h2>\n<p>In terms of language, Visual Basic 2017 also got new features \u2013 Tuples being the most important one. But there is also one new ability of the language which reflects the new language strategy for VB: VB does not need to get every single new feature C# gets. Rather, refining VB should address the VB target\u2019s audience which is usually different from the C# audience and therefore demands different kind of language features and tooling. That said, it <i>is<\/i> very important, that Visual Basic will be able to use every aspect of a library which has been created in C# with features Visual Basic does neither have nor need itself. <i>Ref Returns<\/i> (see below) is a perfect sample for such a scenario.<\/p>\n<h2>Tuples<\/h2>\n<p>When you write methods in VB, which return values, you often find yourself in a situation, where you need to return more than one result value to the caller. If this happens, you got some options:<\/p>\n<ul>\n<li>Create a new Class or a new Structure to integrate the results, and return that Class or Structure.<\/li>\n<li>Work with <i>ByRef<\/i> Parameters, so you can return more than one variable.<\/li>\n<li>Work with Tuples!<\/li>\n<\/ul>\n<p>The framework already has a couple of methods, which work with the <i>ByRef<\/i> alternative. Take a look at how the <i>TryParse<\/i> works, which you find on most of the primitive data types:<\/p>\n<p>This is kind of cumbersome, don\u2019t you think? If <i>TryParse<\/i> could return a Tuple, things would be much easier. Like this:<\/p>\n<p>That is easy to use! Let\u2019s see how Tuples work in detail. Tuple are not new to Visual Basic. They just weren\u2019t very comfortable to use, yet. The new Tuple language feature in Visual Basic 2017 does rely on a different kind of type than <i>Tuple(Of T)<\/i>. For those frameworks, which do not already contain the new type <i>ValueTuple(Of T)<\/i>, you need to install a NuGet package to your project, before you can use this new language feature in your code. This is just for the time being. Later Framework versions will have them included automatically.  To add the NuGet package, in the Solution Explorer open the context menu of your VB project, and click <i>Manage NuGets<\/i>. With the NuGet Manager, find and install the <i>ValueTuple<\/i> NuGet package into your project:<\/p>\n<p><a href=\"http:\/\/devblogs.microsoft.com\/vbteam\/wp-content\/uploads\/sites\/7\/2017\/03\/12TupleNuGet.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/vbteam\/wp-content\/uploads\/sites\/7\/2017\/03\/12TupleNuGet-1.png\" alt=\"12tuplenuget\" width=\"739\" height=\"274\" class=\"alignnone size-full wp-image-7965\" \/><\/a><\/p>\n<p>Before Visual Basic 2017, the only way you could use Tuples looked something like that:<\/p>\n<p>As you can see, there wasn\u2019t a nice way to infer the definition, and Tuple elements could also only be addressed by <i>Item1<\/i>, <i>Item2<\/i>, etc.<\/p>\n<p>This is how you basically use Tuples now, and go back and forth between the old and the new Tuples versions in Visual Basic 2017:<\/p>\n<p>Really cool is that you can name the Tuple elements for the current scope.<\/p>\n<p>Tuples can also be used in expressions. For example, when you want to directly return them from a Function block\u2026<\/p>\n<p>\u2026or when you use them with <i>Select<\/i> in an LINQ-Expression:<\/p>\n<h2>Binary Literals and Digit Separators<\/h2>\n<p>This is only a minor addition to Visual Basic, but it is helpful anyway, and it makes your code easier to read: You can use <i>Binary Literals <\/i>in VB from now on. You already had <i>Hexadecimal Literals<\/i> before \u2013 in the same way, Visual Studio now supports Binary Literals. On top, VB also got digit separators, so numbers with a lot of digits can be read more easily:<\/p>\n<h2>Ref Returns<\/h2>\n<p>We just learned, Tuples are great if you want to return more than one variable back to the caller. Before Tuples, you did this typically with variables which you passed to a method by reference. With a reference, the method cannot only retrieve the content of the variable, the calling method can also change it. Because it is the reference which get passed \u2013 a pointer to the actual content if you will \u2013 the method can also exchange the content: When that variable gets written, that change reflects to the variable which has been passed to the method. <\/p>\n<p>In C# 7, methods can turn the tables on that. C# 7 can now return <i>references<\/i> of result values, which means: When you get the result of a method by reference, your calling code can change the content where this result is pointing to. Why C#? In Visual Basic, you cannot <i>author<\/i> methods which have this ability. But as of Visual Basic 2017 you can <i>consume<\/i> reference return values. Let\u2019s take a closer look at a sample class written in C#, which provides a method to find and replace strings in a sentence:<\/p>\n<p>You see here, <i>FindNext<\/i> returns the word which matches the start characters of the search string. Since <i>FindNext<\/i> returns that element by reference, we can not only read the returned value, we can also write it.<\/p>\n<p>There is one catch, though: for this to work, we need local variables which can be declared <i>ByRef<\/i>. Unfortunately, Visual Basic does not let you do this, so a code like the following, which would work \u2013 if we translated it to C# \u2013 does not so in VB:<\/p>\n<p>So, can we use C# Return by Reference methods in Visual Basic at all? Yes, we can! First, we could use a method or a property returning a value <i>ByRef<\/i> in VB directly. Like this:<\/p>\n<p><a href=\"http:\/\/devblogs.microsoft.com\/vbteam\/wp-content\/uploads\/sites\/7\/2017\/03\/15UseRefReturn1.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/vbteam\/wp-content\/uploads\/sites\/7\/2017\/03\/15UseRefReturn1.png\" alt=\"15userefreturn\" width=\"1398\" height=\"189\" class=\"alignnone size-full wp-image-8005\" srcset=\"https:\/\/devblogs.microsoft.com\/vbteam\/wp-content\/uploads\/sites\/7\/2017\/03\/15UseRefReturn1.png 1398w, https:\/\/devblogs.microsoft.com\/vbteam\/wp-content\/uploads\/sites\/7\/2017\/03\/15UseRefReturn1-300x41.png 300w, https:\/\/devblogs.microsoft.com\/vbteam\/wp-content\/uploads\/sites\/7\/2017\/03\/15UseRefReturn1-768x104.png 768w, https:\/\/devblogs.microsoft.com\/vbteam\/wp-content\/uploads\/sites\/7\/2017\/03\/15UseRefReturn1-1024x138.png 1024w\" sizes=\"(max-width: 1398px) 100vw, 1398px\" \/><\/a><\/p>\n<p>Looks weird, doesn\u2019t it? How come we can assign a value to a <i>method<\/i>? That\u2019s not supposed to work. But if you take the signature into account, by whose tooltip you can recognize a method which is returning <i>ByRef<\/i>, by the way, it starts to make sense: You\u2019re not assigning to the method, you are assigning to the variable the return value is <i>pointing<\/i> to.<\/p>\n<p>The problem still is: this is not helping us. In our example, we\u2019re supposed to assign our replacement string back to the reference only when we know we found the correct word. But testing the word means we\u2019re losing the reference, because there is no way to store it. Or is it?<\/p>\n<p>Well, with a trick, even in Visual Basic we <i>can<\/i> declare a local <i>ByRef<\/i> variable. Visual Basic allows to pass <i>ByRef<\/i> variables to methods, so we can easily declare a helper method which takes a variable <i>ByRef<\/i>, pass the result of the C#-<i>ByRef<\/i>-Function, and use the variable the same way as we would do it in C#. Like this:<\/p>\n<p>That\u2019s exciting! This version also uses Tuples to simplify the handling. Using this helper function now becomes easy:<\/p>\n<p>We\u2019re passing the search term to <i>FindNext<\/i>. <i>FindNext<\/i> returns the found word by reference along with a status, if something has been found (in <i>didFind<\/i>), back to us, and we feed those results directly to our helper method <i>FindNextHelper<\/i> \u2013 both the <i>stringFound<\/i> reference and the <i>didFind<\/i> variable. Since <i>FindNext<\/i> changes the content of <i>didFind<\/i> by reference, this reflects to the <i>didFind<\/i> value we use inside of <i>FindNextHelper<\/i>, which we eventually return to the caller via the Tuple.<\/p>\n<p>With methods like this becoming possible in C#, we will see most likely library developers using them more often. So, wouldn\u2019t it be since, if we could come up with a more generalized form of assigning values to local reference variables in Visual Basic? Well, let\u2019s try this:<\/p>\n<p>Here, we are basically doing the same trick: We are coming up with a way to read and write to a referenced variable by moving the actual code inside a method which retrieves the pointer <i>ByRef<\/i>. And then we use a <i>Func<\/i> delegate to also pass the code which is later used to assign to the <i>ByRef<\/i> variable. In contrast to what we had before, this alternative can be used for different scenarios. Here is ours:<\/p>\n<p>Don\u2019t you think that\u2019s pretty close to the C# version?<\/p>\n<p>Well, that\u2019s all for now.<\/p>\n<p>Go and try out all the new Features of Visual Basic 2017 by yourself! And don\u2019t forget to tell your friends and colleagues what exciting new feature there are in Visual basic 2017!<\/p>\n<p>So long, with best from Germany!<\/p>\n<p>Klaus L\u00f6ffelmann<\/p>\n<p>(follow me on Twitter @loeffelmann)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Visual Studio 2017 just shipped, and with it shipped a new version of Visual Basic. With the new language strategy of the .NET Languages, the focus is again on Visual Basic\u2019s original virtue: Provide editor, debugging and refactoring tools as well as language feature to ease complex tasks and boost every VB\u2019s developer productivity without [&hellip;]<\/p>\n","protected":false},"author":9483,"featured_media":8818,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[5,192,195],"tags":[43,44,91,157,169],"class_list":["post-7855","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-feature-focus","category-featured","category-visual-basic","tag-binary-literals","tag-byref-return","tag-klaus-loeffelmann","tag-tuples","tag-vb2017"],"acf":[],"blog_post_summary":"<p>Visual Studio 2017 just shipped, and with it shipped a new version of Visual Basic. With the new language strategy of the .NET Languages, the focus is again on Visual Basic\u2019s original virtue: Provide editor, debugging and refactoring tools as well as language feature to ease complex tasks and boost every VB\u2019s developer productivity without [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/vbteam\/wp-json\/wp\/v2\/posts\/7855","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/vbteam\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/vbteam\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/vbteam\/wp-json\/wp\/v2\/users\/9483"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/vbteam\/wp-json\/wp\/v2\/comments?post=7855"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/vbteam\/wp-json\/wp\/v2\/posts\/7855\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/vbteam\/wp-json\/wp\/v2\/media\/8818"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/vbteam\/wp-json\/wp\/v2\/media?parent=7855"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/vbteam\/wp-json\/wp\/v2\/categories?post=7855"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/vbteam\/wp-json\/wp\/v2\/tags?post=7855"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}