1 / 20

Visual Basic 2008 Tips and Tricks

Visual Basic 2008 Tips and Tricks. Lisa Feigenbaum Program Manager Microsoft Visual Studio Languages http://blogs.msdn.com/vbteam Lisa.Feigenbaum@microsoft.com. VB 2008 Tips and Tricks. Session Objectives Learn language & IDE productivity features

Télécharger la présentation

Visual Basic 2008 Tips and Tricks

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Visual Basic 2008 Tips and Tricks Lisa Feigenbaum Program Manager Microsoft Visual Studio Languages http://blogs.msdn.com/vbteam Lisa.Feigenbaum@microsoft.com

  2. VB 2008 Tips and Tricks • Session Objectives • Learn language & IDE productivity features • Gain tips, tricks, best practices & answers to FAQs • Agenda • IDE Improvements • New VB Refactorings & IntelliSense • Tips for writing LINQ queries • Using XML in VB 2008

  3. You asked. We listened! • “Stop highlighting my snippets” • “Add my Imports statements for me” • And more… • Performance • Large solutions, web apps, stepping, first-time intelliSense, error list, editor responsivenesshttp://blogs.msdn.com/vbteam/archive/tags/Performance/default.aspx

  4. Demo IDE Improvements

  5. Code just like you think! • Refactor! for VB • Visual Studio Plug-in, available FREE on MSDN • Partnership with Developer Express, Inc. • Total: 16for VB 2005, 14more for VB 2008 • Six Refactorings in C# 2005 & 2008: • Rename • Extract Method • Remove/Reorder parameters • Promote Local • Extract Interface • Encapsulate Field

  6. VB Refactorings in 2005 • Reorder Parameters • Surrounds With • Encapsulate field • Reverse Conditional • Simplify expression • Move initialization to declaration • Split initialization from declaration • Move declaration near reference • Extract Method • Extract Property • Create Overload • Introduce Local • Introduce constant • Inline Temp • Replace Temp with Query • Split Temporary Variable

  7. VB Refactorings in 2008 For VB 8.0: • Create With Statement • Inline With Statement • Widen Scope • Extract Interface • Move Type to File • Introduce Parameter • Remove Unused Parameter • Method to Property • Property to Method(s) • For VB 9.0:: • Extract XML Literals to Resource • Make Explicit • Make Explicit (and Name Anonymous Type) • Make Implicit • Name Anonymous Type

  8. Demo Refactor! 2008

  9. Getting Productive with IntelliSense • Benefits • Less typing • Less memorizing of names and grammar • Fewer errors • IntelliSense Everywhere • New line, Expressions, Keywords, Variables • IntelliSense Features • Transparency • Filter-As-You-Type • Documentation: Keyword & Syntax tips

  10. Demo Getting Productive with IntelliSense in VB 2008

  11. <book> <title/> <author/> <year/> <price/> </book> XML Relational Objects LINQ Language INtegrated Query C# 3.0 VB 9.0 Others… .NET Language Integrated Query LINQ toObjects LINQ toDataSets LINQ toSQL LINQ toEntities LINQ toXML

  12. Querying Relational Data Accessing data the hard way Queries in quotes Dim c As New SqlConnection(…) c.Open() Dim cmd As SqlCommand( _ "SELECT c.Name, c.Phone “ & _ "FROM Customers c” & _ "WHERE c.City = @p0") cmd.Parameters("@p0“) = "London" Dim dr As DataReader= c.Execute(cmd) While (dr.Read()) Dim name As String = r.GetString(0) Dim phone As String= r.GetString(1) Dim date As DateTime = r.GetDateTime(2) End While r.Close() Loosely bound arguments Loosely typed result sets

  13. Querying Relational Data Accessing Data with LINQ Classes describe data Public Class Customer … Public Class Northwind Inherits DataContext Public Property Customers As Table(Of Customer) … End Class Tables are like collections Compile-time checking Dim db As New Northwind(…) Dim contacts = _ From custin db.Customers _ Where cust.City= "London" Select cust.Name, cust.Phone For Each custInfo in contacts ColdCall(custInfo.Name, custInfo.Phone) Next Integrated query syntax Strongly typed results

  14. Demo LINQ Tips & Tricks

  15. LINQ Demo SummaryBest Practices, Gotchas, FAQs • IntelliSense • Query result shape • Aliasing columns • Composing queries • Ordering operators • Designing for Performance • The Aggregate operator • Understanding Deferred Execution • Debugging • Running SQL from VB/C#

  16. Demo Say it in XML!

  17. XML in VS 2008Topics Covered • Inline XML in VB • Embedded Expressions • XLinq • Axis Properties • Children, Descendants, Attributes • XML IntelliSense for VB • XML Case Sensitivity • Multi-Line Strings

  18. Summary • What We’ve Seen • IDE Improvements • Refactor! • New IntelliSense • LINQ • Integrated XML Support • Call to Action • Use the demo code. Try it out. • Look up the resources. • Tell us your feedback & what you want to see in the future.

  19. Resources Visual Basic Developer Centerhttp://msdn.com/vbasic Blogshttp://blogs.msdn.com/vbteam (VB Team) http://blogs.msdn.com/bethmassi (Beth Massi) Refactor!http://msdn.microsoft.com/vbasic/bb693327 Visual Basic Forumshttp://forums.msdn.microsoft.com/en-US/tag/visualbasic/forums/ Connecthttps://connect.microsoft.com/VisualStudio

  20. THANK YOU! • Future Directions for VB: Thurs 14:30, Rm 6 • http://blogs.msdn.com/vbteam • Lisa.Feigenbaum@microsoft.com

More Related