Article Options
Premium Sponsor
Premium Sponsor

 »  Home  »  .NET Newbie  »  Using the “Code Snippet Editor for Visual Basic 2005”  »  Create and Edit Snippets
 »  Home  »  Visual Studio 2005  »  Using the “Code Snippet Editor for Visual Basic 2005”  »  Create and Edit Snippets
Using the “Code Snippet Editor for Visual Basic 2005”
by Dave Barr | Published  05/24/2006 | .NET Newbie Visual Studio 2005 | Rating:
Create and Edit Snippets


This opens the window where you create and edit snippets. Near the top-middle of the screen, make sure the "Editor" tab is pressed. Type the following code inside the Editor window.

Dim MsgQuesText As String = "Question to prompt user goes here"

Dim MsgQuesTitle As String = "MessageBox title goes here"

Dim MsgQuesBtns As MessageBoxButtons = MessageBoxButtons.YesNo

Dim MsgQuesIcon As MessageBoxIcon = MessageBoxIcon.Question

Dim MsgQues As DialogResult = MessageBox.Show(MsgQuesText, MsgQuesTitle, MsgQuesBtns, MsgQuesIcon)

If MsgQues = Yes Then

'Yes was pressed.

'Code Goes Here


'No was pressed.

End If













[Personally, I type and test all of my code snippets in Visual Studio and later paste them in the Editor.] Now toward the lower-middle of the screen make sure the "Properties" tab is pressed.

Fill in the properties to match below.

Title: My YesNo Message

Shortcut: YesNo

Description: This is my YesNo Message Snippet Demo for




Your screen should look similar to the image above.



Now navigate to the "Imports" tab. Under Namespace type: System.Windows.Forms.DialogResult

In the Editor window, select the following text (without quotes) in your code:



Now navigate to the "Replacements" tab...



...and press the addition symbol [+]. This will create the replacement properties for the MsgQuesText String in your code. You can leave the "ID" and "Defaults to" properties as they are.

Under the "Tooltip" property, type: Type the question to ask the user.



Your screen should look like the image above. Go back in the Editor window and select: MessageBox title goes here (without quotes). Then add a replacement for that text the same way. For the Tooltip property type: Title of the YesNo MessageBox.



That's all there is to it!



Press the "Save" button located above the "Editor" tab.



Now press the "Sync" button located two buttons down from the "Save" button. Close the Snippet Editor.   It's time to use your new snippet!

Sponsored Links