This thread is going to be devoted to giving helpful hints about VB.NET, not in the code sense, but in a general sense. I would like to get a long list going, but to avoid this from being a runaway thread, it will be locked. If you would like to submit something, please PM me. I will review your submission and if it fits the thread, I will post it here. People who submit valid tips will be given credit for the submission.
This is more of a tip of the day type thread. So please no CODE examples like "how to cancel a keypress", that is a topic for its own thread (which there are many of already). What I am looking for is more tips and tricks for the IDE, the framework, the help, etc....
All tips currently are from VS.NET 2003, but most (if not all) still apply in both 2002, and 2005 version of Visual Studio.NET
GET YOUR EXAMPLE VB CODE HERE!!!!!
The 101 VB.NET Examples are now located right here, for your downloading pleasure.
Don't cut and paste controls that have event code in them. It removes their handlers which can cause massive headaches.
For example. If you add a button to a form, put some code in its click event, then cut and paste it back to the form, the code in the click event will no longer work.
What happens is the code is still there, but it removes the "Handles button1.Click" from the end of the sub since the IDE is using the background compiler.
You can only imagine what would happen if you had 100 controls on your form and you cut and paste them for some reason (like putting them in a frame or panel)
Drag the controls instead, they will retain the links to the handlers.
Using the How-To XML Comments sample app in the sticky 101 VB.NET samples, you can add comments to your own classes in your DLLS
for example, when you are coding and use one of microsofts functions/properties in one of the .net framework classes, each param of the function has a comment tooltip in intellisense that describes it, but when you make your own class, there is no such place to do something like this. With the XML comment sample, you can do this with ease.
This is very useful when your DLLs will be used by others because it makes them even more self descriptive
Some members of classes in the framework are invisible to VB.NET by default. While many may truly be advanced members that you will not likey use, some are common ones (possibly marked advanced in error!)
In the options menu under text editor -> basic, you can turn on these advanced members.
SIDE NOTE: These memebers are shown, not hidden by default in C#
Collapses all the regions in the code in the current file.
ctrl+m+m will collapse/expand the current code block
alt+E+G (hold alt, hit E and then G)
Prompts you for a number and then takes you to that line number in the current code file.
You can also set different settings based on the build type you are in (i.e. Debug, Release, Other). For instance I also change the output folder for release mode so it goes to the actual production location. I also set certain commandline prompts for another that I named DebugWithoutLogon. The app is then set up to bypass logon and set certain test flags so during debugging I don't have to login and do those things every time.
ctrl+spacebar in the .NET IDE will bring up intellisense wherever you are, this includes the IDE attempting to autocomplete variables you are typing (very good when you have some LONG variable names, or if you just can't remember what you called that variable 4 modules over)
VB AT THE MOVIES
Microsoft has a ton of VB movies you can view online that show you how to do various different things with VB.NET.
What is great about this, is that they show you what they are talking about instead of you just having to read about it. It is the perfect visual aid. You can pick a topic you know little about, and sit back while they give you a short lesson on it.
WEBCASTS
The MSDN has webcasts you can load up at any time that give good insight on how to do things in the .NET world.
While they currently don't have any VB.NET webcasts listed, there are some other ones that are very worthy of taking a look at.
Such as:
Object-Oriented Concepts and Best Practices- Level 300
Patterns for Successful .NET Application Development - Level 200
Securing Your Data and Applications with Microsoft .NET - Level 300
Tip #2 talked about some sample code to create documentation for classes and such that you write in VB.NET
well here is a link to an addin to Visual Studio.NET that will help to make your documentation as easy as can be. This was written by MS, so no worries about installing it (well no more than the usual MS program )
Installing .NET applications to network drives
When I first noticed this, it really worried me. If you install a .NET app to a network drive, the exe will not have full trust running in the .net environment (by default). I think this is sort of silly as any mapped network drive should be considered safe (but I guess I do see the point in its existance)
Well I found an article which talks about an exe called caspol. It is in your framework directory at
C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322
and it is used to give/takeaway permissions (the same as the "Microsoft .NET Framework 1.1 Configuration" GUI basically in Administrative Tools) but you can run it silently, and run it without end user interaction. This means you can include it as part of your install if the user selected to install to a network drive.
You can use special comments to not only provide commented information, but to also create spots where you know you will need to later reference, either to fix code, write code, or basically anything you want.
There are some default keywords you can use like HACK, TODO, etc, but you can also create your own.
They will appear in the tasklist (where build errors appear) and you can filter the list to show them or not show them at any time by right clicking on the list
Be very careful when uninstalling any of the Visual Studio 2005 BETA editions to either install a newer beta, or to just remove it completely from your system.
Often times you will put files in your bin folder when working on a windows forms app because the bin folder is where the compiled exe goes. If you wanted to have a textfile read in by your app, and is supposed to be in the same directory as your app, you would place it in the bin directory. Likewise if your app wrote to a textfile that was in its own directory.
Here is a cool little trick that can save you some time if you frequently visit your bin folder for one reason or another.
In the Solution Explorer, many of the files/folders that are not considered "crucial" to your project are not shown even though they exist in the actual file structure of the solution on your hard drive. There is a button you can click that will show these hidden files (see picture). Once you click that button, the files/folders will appear, although slightly faded out to show you they are hidden. If you right click on a folder, you can select "Include in Project" which will add that item to your Solution Explorer as if it was any other file that was already there. If you do this for a file that was in a folder, it will add the folder as well.
As you can see this can be used for many different situaitons, but the one I personally have been using it for, is to show my bin folder as part of the Solution Explorer, so I can access items in it easily. If your app writes an XML file, you can easily double click it right from the solution explorer and view/edit the xml file right in the IDE's text editor.
Since this thread is 10 years old, I have unstuck it. However if you guys want to come up with some more modern tips and tricks, maybe we will start a new sticky.