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

Else

'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 http://VbCity.com

Author: 3-bSoftware.com

 

 

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!

Comments    Submit Comment

Comment #1  (Posted by an unknown user on 05/25/2006)
Rating
Very informative and straight forward. Articles like this are always appreciated!!!

-Do
 
Comment #2  (Posted by an unknown user on 05/29/2006)
Rating
This is a Great Job of explaining in detail and showing in graphics just what you should do. This is truly a great way to teach. Thank You.
 
Comment #3  (Posted by sp!ke on 07/16/2006)
Rating
Great article. You got me all juiced up for using it, and then I found out that for some reason this utility only edits code snippets for VB, not C#!
 
Comment #4  (Posted by sp!ke on 07/16/2006)
Rating
Please disregard my previous comment - there is an Options button that allows you to choose which languages to display snippets for, and C# is one of them.
 
Comment #5  (Posted by an unknown user on 09/01/2006)
Rating
DAVE PASSED AWAY ON JULY 31, 2006
 
Comment #6  (Posted by an unknown user on 11/21/2006)
Rating
This was the clearest tutorial I've ever read. Everything was as written in tutorial and the snippet ran as described. This man should have written the bible on VB. Other authors should read this article to keep in their heads what their tutorials should contain. There was nothing left out of this tutorial and there ALWAYS is.
 
Comment #7  (Posted by an unknown user on 12/20/2006)
Rating
Another incredible article by Dave, we will all miss him if it really is true that he has passed on. My condolences to the family and good energies your way.
 
Comment #8  (Posted by an unknown user on 03/01/2007)
Rating
Godspeed Dave!

You're informative articles and dedication to helping the development community will be sorely missed.

This article in particular has helped me greatly.
 
Comment #9  (Posted by an unknown user on 07/16/2007)
Rating
Easy to follow and very usefull
 
Comment #10  (Posted by an unknown user on 07/19/2007)
Rating
very good, I am developer, and much so have use snippet
 
Comment #11  (Posted by an unknown user on 12/31/2007)
Rating
What a fruitful article as being a newbie. Life is nothing without appreciation, as this article remain alive for someone roles is an instrument to his 2nd coming journey.
 
Sponsored Links