Download presentation
Presentation is loading. Please wait.
Published byHarold Owens Modified over 9 years ago
1
Visual Basic Tip Tricks and Other Advanced Topics Bill McCarthy Nick Randolph DEV313
2
What we’ll cover.. Getting started Profiles & Settings, Options, and Templates Writing Code (or not) My, data sources, snippets, VB Snippet Editor, generics, custom events, operator overloading, error correction Debugging Code Edit and Continue, Object work bench, Immediate window, Debugging enhancements
3
Profile and Settings Profiles set all the customisations Window layout Keyboard shortcuts Preferred language templates Start page URLs Choosing the right profile General Developer Visual Basic Developer
4
Settings Options Turn Off Animation Do Show the Start Page Word wrap, with line numbers and visual glyphs Turn ON: Option Strict Option Strict Show Advanced Build Configuration Show Advanced Build Configuration Always Show Solution Always Show Solution Show OutPut Window when build starts Show OutPut Window when build starts Prompt for Symbolic Rename Prompt for Symbolic Rename Show Misc. Files in Solution Explorer (20) Show Misc. Files in Solution Explorer (20)
5
Customize Your Layout Customize your window layout for code editing Do this for Debug mode as well 1. Create a simple console application. 2. Set a break point, then run the app. 3. Now set your debug window layout When happy, save your settings
6
Command Bars and Menus You can now customize Short Cut menus !! “Solution Platform” and “Solution Configuration” command bar combo box are not in the Commands list Import the General Development toolbar and menus, and customize from there.
7
Take It With You Now you have customized your environment, save it to disk. Also put it on a USB thumb-drive and take it with you
8
Project and Item Templates Per machine AND per user The user path is customizable Tools… Options.. Projects And Solutions New.vstemplate file format VStemplate schema C:\Program Files\Microsoft Visual Studio 8\Xml\Schemas Easy Export Wrapped using zip files
9
Creating templates First create your default project then select File Export Template Customize further using standard replacements in the code files new IWizard Interface
10
IWizard references to add Microsoft.VisualStudio.CommonIDE.dll C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\microsoft.visualstudio.c ommonide.dll EnvDTE.dll C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\PublicAssemblies\EnvD TE.dll
11
Project and Item Templates
12
Quick Tip To stop the default designer of a base class from being opened, add the following attribute to the derived class: To assign a property to a category in the Property grid, add attribute to property:
13
The My application framework SettingsResources Application Instancing More…
14
Snippets Code reuse for commonly used patterns VB ships with around 500 Extensible XML document: snippetformat.xsd Has “replacements” that can be specified when snippet is used No editor within VS2005 SnippetEditor built by the community, available from: http://msdn.microsoft.com/vbasic/downloads/2005/tools/snippeteditor/
15
Operator Overloading + + (unary) - - (unary) * \ / ^ & Like Mod And Or Xor Not << >> = (comparison only) <> < <= > >= CType IsTrue IsFalse + - * / ….. CtypeWideningNarrowing
16
Custom Events Ability to specify what happens when you: Add event listeners Remove event listeners Raise events Using snippets to remember all the “base” code
17
Why use custom events ? Binary serialization EventHandler storage optimizations Delay hooking expensive resources Async invocation Error handling
18
Generic Constraints Interface Public Class thisClass(Of t As IComparable) Class/Structure Public Class thisClass(Of t As Class) New Public Class thisClass(Of t As New) Multiple Public Class thisClass(Of t As {IComparable, New})
19
Generic Collections List(Of T) ObjectModel.Collection(Of T) ComponentModel.BindingList(Of T)
20
Generic Delegates Action(Of T) Comparison(Of T) Compares an object to the current object (similar to compareTo) Converter(Of TInput, TOutput) Converts type 1 to type 2 EventHandler(Of TEventargs) Predicate(Of T) Indicates if a particular condition is true for the object argument
21
Debugging Support Immediate Window Object Work Bench Edit & Continue
22
Debugger Debugger.IsAttached Determine if a debugger is attached Debugger.Launch Launches a debugger (if not attached) Debugger.Break Equivalent to a breakpoint Will launch the debugger if not attached
23
Debugging DebuggerDisplay Single line representation Hover over object Can add property values {} DebuggerBrowsable Broken in Beta2 Missing Enum value Doesn’t function Determines whether the variable/property is collapsed, never displayed, root hidden or expanded
24
Debugging DebuggerHidden Debugger won’t stop in method, property or constructor Can’t set breakpoints in there either DebuggerNonUserCode Class/Structure, Method, Constructor, Property Prevents stepping into and appearance in UserCode section of call stack
25
Debugging DebuggerStepThrough Debugger won’t step into method Will stop for breakpoints (although DebuggerTypeProxy Shows alternative type instead of type being debugged Must have a constructor with single argument of the type being debugged DebuggerVisualizer Allows user code to run when magnifier is selected Must inherit from DialogDebuggerVisualizer
26
We invite you to participate in our online evaluation on CommNet, accessible Friday only If you choose to complete the evaluation online, there is no need to complete the paper evaluation Your Feedback is Important!
28
© 2005 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.