Increase your productivity using Visual Studio code snippets
In Microsoft VS 2005, Microsoft introduced a new functionality which helps developers to increase the productivity, Code Snippets.
The code snippets can be inserted using Right Click > Insert Snippet command (Image1).

Right Click > Insert Snippet(Image1)
And also you can use Snippet Manager(Image2), to check the shortcuts for snippets and by typing the shortcut and pressing [Tab] key will insert the snippet.

Snippet Manager (image2)
For inserting snippets for Property, type property and press [Tab] will insert code for a property(Image3)
Use the Snippet Manage to find the shortcuts, for Inserting snippets.
Some sample code snippets shortcuts
Foreach – For Each loop
For – for loop
Tryc – Try catch block
Trycf – Try Catch Finally block
If – If condition
Property – Property Declaration
Sub – Procedure Declaration
Function – Function Declaration

Property snippet inserted(Image3)
If you are not getting Snippet Manager, Right Click on Toolbar, Select Customize, from Command Tab, Choose Tools from Categories list, and drag Code Snippet Manager to the toolbar. Also you can create your own snippets using SnippetEditor.msi from Microsoft, you can download snippet manager from Microsoft.
You can get more information about snippets from Visual Studio 2005 Code Snippets on MSDN and you can download Visual Basic Code Snippet Editor from MSDN.
Happy Coding
Update : If you are using Visual Studio 2008 – You will get a context menu item to show / hide snippet highlighting
Windows registry with .Net 2.0
To access the registry from Classic VB 6.0, you can use default Savesettings and GetSettings methods, it will will create a key under
“HKEY_CURRENT_USER\Software\VB and VBA Program Settings\”. But if you want you own custom locations, you need in Windows API. In .Net
Microsoft provided a new set of classes to work with Windows Registry, under Microsoft.Win32 namespace.
Classes to working with Registry
- Registry class
This class contains members to access the registry keys.
Url: MSDN – Registry Class - RegistryKey class
This class provides method to manage Registry keys and Values.
Url:MSDN – RegistryKey class
Sample code which stores and retrieves size of the window, on closing and on loading respectively using Registry class.
Imports Microsoft.Win32
Public Class frmMain
Private m_WindowSize As Size = Me.Size
Private m_Settings As RegistryKey
Private Sub frmMain_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
Unload()
End Sub
Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.Init()
Me.Size = m_WindowSize
End Sub
Private Sub UpdateWindowSize(ByVal WindowSize As Size)
m_Settings = Registry.CurrentUser.OpenSubKey("RegistryApp", True)
If m_Settings Is Nothing Then
m_Settings = Registry.CurrentUser.CreateSubKey("RegistryApp", RegistryKeyPermissionCheck.ReadWriteSubTree)
End If
m_Settings.SetValue("Width", WindowSize.Width, RegistryValueKind.String)
m_Settings.SetValue("Height", WindowSize.Height, RegistryValueKind.String)
End Sub
Private Function GetWindowSize() As Size
m_Settings = Registry.CurrentUser.OpenSubKey("RegistryApp", True)
If m_Settings IsNot Nothing Then
m_WindowSize.Width = m_Settings.GetValue("Width")
m_WindowSize.Height = m_Settings.GetValue("Height")
End If
Return m_WindowSize
End Function
Private Sub Init()
m_WindowSize = GetWindowSize()
End Sub
Private Sub Unload()
UpdateWindowSize(Me.Size)
End Sub
End Class
The RegistryValueKind enum, set the value types. And RegistryKeyPermissionCheck enum , Retrieves the specified subkey for read or read/write access.
