Coding assistance in Visual Basic
All ReSharper's coding assistance features available in C# are also supported in Visual Basic. You can find the detailed information on these features in the corresponding topics of the Coding assistance section.
In this topic, you can find some examples of using coding assistance features in Visual Basic.
Syntax highlighting
You can establish a custom font and color scheme, for more information, see Configure fonts and colors.
Default syntax highlighting:
![ReSharper: Syntax highlighting in VB.NET ReSharper: Syntax highlighting in VB.NET](https://resources.jetbrains.com/help/img/dotnet/2023.1/Coding_Assistance__Syntax_Highlighting__VB.NET.png)
Code completion
Code Completion features help you write code faster by providing a set of items to complete based on surrounding context. For more information, see Code completion (IntelliSense).
Three Code Completion features are available in Visual Basic:
Automatic and basic completion
Basic completion suggests namespaces, types, methods, fields, properties, and so on.
Smart type-matching completion
Smart completion filters items in code completion list according to the type expected in current context. Look at the example below, only those items that have string
type are displayed in the list.
![ReSharper: Code completion in VB.NET ReSharper: Code completion in VB.NET](https://resources.jetbrains.com/help/img/dotnet/2023.1/ReSharper_by_Language__Visual_Basic__Smart_Completion.png)
Import symbol completion
Import Symbol Completion provides completion items for types and extension methods that are not visible through import directives in current context.
![ReSharper: Code completion in VB.NET ReSharper: Code completion in VB.NET](https://resources.jetbrains.com/help/img/dotnet/2023.1/ReSharper_by_Language__Visual_Basic__Import_Symbol_Completion.png)
Examples of context actions
ReSharper provides a set of context actions that target Visual Basic code. You can find the full list of these actions in the Code Editing | Visual Basic | Context actions page of ReSharper Options. If necessary, you can also disable some of the actions using this page.
As soon as a context action becomes available for the current caret position, ReSharper displays the corresponding action indicator to the left of the caret. Sometimes however, ReSharper provides several contextually available features for the current caret position. In this case, the action indicator corresponding to the action with the highest priority is shown, and all other actions only appear when you expand the action list by clicking on the action indicator or pressing Alt+Enter Context actions have the lowest priority, therefore, they often appear at the bottom of the action list.
Here are some examples of context actions for Visual Basic:
Add new format item
If you need to add some dynamic data to a string literal, use this context action. String.Format
method call, adds a placeholder at the current caret position and lets you specify the corresponding parameter.
Change member visibility
If you need to adjust member visibility, ReSharper provides a context action that allows doing this quickly.
![ReSharper: 'Change member visibility' context action in VB.NET ReSharper: 'Change member visibility' context action in VB.NET](https://resources.jetbrains.com/help/img/dotnet/2023.1/ReSharper_by_Language__Visual_Basic__Context_Actions__change_visibility_01.png)
![ReSharper: 'Change member visibility' context action in VB.NET ReSharper: 'Change member visibility' context action in VB.NET](https://resources.jetbrains.com/help/img/dotnet/2023.1/ReSharper_by_Language__Visual_Basic__Context_Actions__change_visibility_02.png)
Convert Function to Sub
In case you want to convert a Visual Basic Function to a Sub, there's the corresponding context action as well.
![ReSharper: 'Convert Function to Sub' context action in VB.NET ReSharper: 'Convert Function to Sub' context action in VB.NET](https://resources.jetbrains.com/help/img/dotnet/2023.1/ReSharper_by_Language__Visual_Basic__Context_Actions__convert_function_to_sub_01.png)
Convert to property with backing field
You can easily transform an automatic property to a property with backing field. Place the caret at the name of an automatic property and press Alt+Enter. ReSharper suggests the appropriate context action.
![ReSharper: 'Convert to property with backing field' context action in VB.NET ReSharper: 'Convert to property with backing field' context action in VB.NET](https://resources.jetbrains.com/help/img/dotnet/2023.1/ReSharper_by_Language__Visual_Basic__Context_Actions__automatic_property_01.png)
Create overload without parameter
For each parameter of a function there's a context action that will create a function without that parameter which calls the original function.
![ReSharper: 'Create overload without parameter' context action in VB.NET ReSharper: 'Create overload without parameter' context action in VB.NET](https://resources.jetbrains.com/help/img/dotnet/2023.1/ReSharper_by_Language__Visual_Basic__Context_Actions__create_overload_01.png)
![ReSharper: 'Create overload without parameter' context action in VB.NET ReSharper: 'Create overload without parameter' context action in VB.NET](https://resources.jetbrains.com/help/img/dotnet/2023.1/ReSharper_by_Language__Visual_Basic__Context_Actions__create_overload_02.png)
Implement member
After you add a new member to a base class, the next logical step is to implement this member in all classes derived from the base class. You can write code manually, but a better decision is to apply the appropriate context action.
Rearrange code
Rearrange code elements is available in Visual Basic as well. For example, you can move a member declaration up or down within a type.
![ReSharper: Rearranging code in VB.NET ReSharper: Rearranging code in VB.NET](https://resources.jetbrains.com/help/img/dotnet/2023.1/ReSharper_by_Language__Visual_Basic__Moving_Code_Elements_01.png)
You can move a statement out of or into a block of code. For example, to move If
statement out of For Each
loop, press Control+Alt+Shift+ArrowLeft.
![ReSharper: Rearranging code in VB.NET ReSharper: Rearranging code in VB.NET](https://resources.jetbrains.com/help/img/dotnet/2023.1/ReSharper_by_Language__Visual_Basic__Moving_Code_Elements_02.png)
You can reorder parameters of a method call or a method declaration. For example, to move FileId
argument to the right, press Control+Alt+Shift+ArrowRight.
![ReSharper: Rearranging code in VB.NET ReSharper: Rearranging code in VB.NET](https://resources.jetbrains.com/help/img/dotnet/2023.1/ReSharper_by_Language__Visual_Basic__Moving_Code_Elements_03.png)