Article Options
Premium Sponsor
Premium Sponsor

 »  Home  »  .NET Newbie  »  Using the “Code Snippet Editor for Visual Basic 2005”  »  Using The Snippet
 »  Home  »  Visual Studio 2005  »  Using the “Code Snippet Editor for Visual Basic 2005”  »  Using The Snippet
Using the “Code Snippet Editor for Visual Basic 2005”
by Dave Barr | Published  05/24/2006 | .NET Newbie Visual Studio 2005 | Rating:
Dave Barr
Not much to tell, so for now view some of my custom logo designs, and a photograph of mine that made it to the local newspaper. 

View all articles by Dave Barr...
Using The Snippet


Create a new project and double click on the form. Click your mouse inside the Form's load event. Right click and choose "Insert Snippet...".



Navigate through the folders to your custom snippet by double clicking. Pause when you get to your "My YesNo Message" Snippet and only click once to select it. Notice the tooltip? If you wanted to add the snippet, all you would do is double-click on the snippet's name. We don't want to add it yet so click somewhere on the page itself to close the snippet navigation.



That was the long way to add a snippet; I want to show you the shortcut now. If you accidentally added the snippet, then just delete it from the event before proceeding. Do you remember what we named the shortcut for your snippet? We named it YesNo. So type yesno inside the form's load event and press the tab key.



There's the snippet, all typed out and ready to go! [Personally, I would have typed something more meaningful for my message title so that I don't have to change it now. My real snippet's title is: Message and in most cases I just leave it that way.]  You will notice that the snippet automatically put your included import statement at the top of the code.



Double-click on the first replacement string, "Questions to prompt user goes here". The entire replacement becomes highlighted so all you need to do is start typing. Type: Would you like to continue and load the page?

Now do the same for the replacement, "MessageBox title goes here" and type: Message

Under the comment, "'Code Goes Here" in the If...Then...Else block, type: MessageBox.Show("Ok, loading form")

and under the comment, "No was pressed" type: Me.Close()

The snippet is ready to run. Press F5 and try it out.



If you press "No" the form should just close without ever opening. If you press "Yes", you should see the "Ok, loading form" message. Press OK and the form should load.



You have completed the Using the "Code Snippet Editor for Visual Basic 2005" tutorial. Thank you for participating with my first article!

How would you rate the quality of this article?
1 2 3 4 5
Poor Excellent
Tell us why you rated this way (optional):

Article Rating
The average rating is: No-one else has rated this article yet.

Article rating:3.56451612903227 out of 5
 62 people have rated this page
Article Score29600
Sponsored Links