Code Snippet Shortcuts VB.NET - vb.net

I need some small information about visual studio. Presently, I am using VS 2010. When we type "ctor + tab + tab", it will create code snippet for "Constructor" if the language Visual C#. Similarly, for prop,//,etc...
But, its not the case with VB.NET language. Can you guys provide some list of shortcuts which VS(VB.NET) supports.
Thanks in advance.

Code snippets are highly customizable code fragments intended to accomplish simple to intermediate tasks quickly; they can be inserted into your code with just a few keystrokes.
You can insert IntelliSense Code Snippets using the Code Snippet Picker or typing the shortcut name of the snippet and pressing Tab. When you know the name of the snippet you want to insert, you can do so by typing its shortcut followed by the TAB key. When you have to browse for an appropriate snippet, you can use the snippet picker, which gives you categorized lists of snippets to choose from.

Visual Basic includes a code library consisting of several hundred pieces of code, called IntelliSense code snippets, that are ready to be inserted in your application. Each snippet performs a complete programming task such as creating a custom exception, sending an e-mail message, or drawing a circle. You can insert a snippet into your source code with a few mouse clicks. You can also create your own snippets that suit your business needs, add them to the library, and then use them when needed.

Related

VBA: How to edit Attribute inside a Procedure?

I recently discovered that is possible to use Attribute [ProcedureName].VB_*, inside procedures.
What I found
But this code is not shown inside VBA Editor.
Same code in VBA Editor (left) and exported .cls in Notepad (right)
When Attribute is written inside VBA Editor, it's marked red
Attributes added manually in the VBA Editor
The question
Is there more elegant way how to maintain these Attributes than export class module, edit them outside and import them back (facepalm needed)?
Also I haven't found official documentation for these Attributes (on https://learn.microsoft.com/en-us/office/vba/).
Thank you!
PS: As always I hitted something interesting and related just after Question had been sent. A step-by-step example on Microsoft Docs site suggests to do it by Export-Edit-Import method :(
The process for getting Rubberduck to apply annotations requires a few steps.
Execute a Rubberduck refresh. If the code does not compile cleanly then Rubberduck will show a 'Parse Error'. In this case you need to sort out your code first. This can be an issues if you are applying Rubberduck to an existing code base. If not then learn to compile and rubberduck.Refresh early and regularly (i.e. after every complete edit)
If Rubberduck parses successfully you then need to look at Rubberduck.Code Inspections. To take action about an inspection result select the individual result and right click. This will provide a list of actions that can be applied by Rubberduck.

Make code foldable at custom locations using specific comments in Visual Studio Code?

I am working with Visual Studio Code to create react native apps. To get a better overview of my code, I would like to collapse specific code blocks. But I want to be able to decide where and what to collapse. For this, it would be really nice if a custom comment combination would trigger a folding button on the sidebar.
For example, if I write //- instead of only // at the beginning of a line it should add a collapse button on that line. Is this (or something similar) possible in Visual Studio Code?
Look at code folding by regions. See How do I collapse sections of code in Visual Studio Code for Windows?.
But I don't think you can alter the region syntax to whatever you want, it is defined by the language configuration.
Try // #region and // #endregion for javascript react. (or //#region and //#endregion)

Event handler code snippet absent from PCL project in Xamarin.Forms, VS 2017

Previously in UWP apps I had used a code snippet that generated an event handler and linked it to a xaml control's event. For instance, a button and I type Click and it prompts me to create a new event handler.
In Xamarain forms, I get the same thing in UWP version of the app, but not in the MainPage.xaml inside the first project. In other words, if my app is named WorkingDemo, the snippet works in WorkingDemo.UWP project, but not in WorkingDemo. In previous versions this section was called the PCL i believe.
Also, if I type out:
Click=""
and put my cursor between the quote and hit ctrl+space nothing happens at all.
I recommend that you download Resharper for Visual Studio, it is very good and helps not only in these situations. You quickly get used to it.
About the license: I use a student license, they activate it very quickly
Almost all .Net programmers use it as their assistant
Resharper really slows down the launch and operation of visual studio. But don't always need to pay :)
As for visual studio, there is a workaround: you can write Clicked = "" in Xaml, then go to the code file and somewhere to write for example button.Clicked + = ..., then IntelliSense prompts you to generate the handler, you generate it and delete the button .Clicked + = ... from the code file.
The last thing you need to do is copy the name of the generated event handler to the xaml markup

How do I output code while debugging in Visual Basic 2010?

When I'm debugging my application something is not right, and I can't continue.
So is it possible to see the output code of my app while I'm testing it to see what is wrong?
I open the output window but nothing happens in there it's just stay blank.
In two words: I want to see what my app is actually doing while I'm testing it.
I'm using Visual Studio 2010.
So is it possible to see the output code of my app while im testing it to see what is wrong?
Yes, but you actually have to output something, otherwise nothing will show up. In VB.NET (which is the language you're using if you have Visual Studio 2010), this is accomplished with the following code:
Debug.Print("Here is some text that will be output.")
The documentation for the Debug.Print method is here. In order to call it like that, you will also have to have imported the System.Diagnostics namespace. You do so by placing the following line at the top of your code file (with all the other statements that look like it):
Imports System.Diagnostics
The output will automatically appear in the Output Window. If you still don't see anything, ensure that output is not being redirected to the Immediate Window instead: Tools -> Options -> Debugging -> General -> uncheck the option "Redirect all Output Window text to the Immediate Window".
Confusingly, you use the word "code" in your question, saying that you wish to "see the output code of [your] app while testing it". I'm not sure if by "code" you actually mean "output", in which case the solution above will work for you.
If you actually mean code, as in your program's source code, then you can use the Break toolbar button (or press Ctrl+Break) in the IDE to pause the execution of your program. This will automatically dump you back into the code editor with the currently-executing line of code highlighted.
Visual Studio has some very powerful debugging tools. If you don't already have a general idea of how to use them, I strongly recommend picking up a book on either it or VB 2010 that will teach these things to you. They can be very confusing to learn by trial and error, but are not all that difficult if you have a good guide. Spend that time debugging your code, not figuring out how to use the IDE.

Modify VB property template in VS2008

In VS2008 (VB.NET) when you type Public Property X As SomeType
and press enter, VS auto-generates the rest of that property definition for you.
I would like to be able to customize what VS generates.
Any thoughts on how to go about that? VS must have a template for it somewhere, eh?
Thanks.
I think that the Property generation uses an inbuilt macro. I haven't found it in the list of sample macros provided with VS. However, you can edit the DefineAProperty.snippet* file to modify it as per your requirement. Personally, though, I would suggest creating your own snippet rather than modifying the pre-installed ones.
Some links to more information/Snippet Editors:
Creating and using Snippets - MSDN
Code snippet editor for VB 2008
Snippet Designer - CodePlex