• Beth Massi - Sharing the goodness

    Last Day at DevTeach

    • 5 Comments

    All good things come to an end. My last day at DevTeach I filled in for a speaker that got caught at the border at the last minute and presented a session focusing completely on LINQ to XML in Visual Basic 9. I went through a lot of examples and got really great reviews for the session. Most of the applications I showed you've already seen here, but there were a couple new ones that I'll post in the next coming days, including a clean, simple app that uses Virtual Earth to map out customers in the Northwind database.. in one LINQ to XML query of course. :-) I think overall people were very impressed with the technology and there was a lot of excitement about being able to use it now!

    Of course, what would be the last day at DevTeach without pulling a prank on Beth Massi? Yes the Mad Mexican (as they call him) strikes again and this time it was me that was blessed with the words "I love you BETH" on a round, hairy belly of a crazy Canadian. Here's the video!

    Thanks to Jean-Rene and all the rest of the DevTeach crew for another awesome conference. See you in Toronto in May!

    Enjoy!

  • Beth Massi - Sharing the goodness

    DevTeach Part Deux

    • 3 Comments

    My second day at the conference has been the best so far. First off, I presented a great session on "What's New in Visual Basic 9" and it was a hit! It may have been because of the beer that was available outside ;-) but I think it was because of all of the awesome features I showed. Okay, I did draw a blank on one demo but recovered with lots of laughs after blaming it on the beer.

    What was really fun was the 20 minutes of LINQ to XML I showed. People went nuts over the feature. Someone said, "So we don't need XQuery?" and I went up close to the mic and created one of my many sound effects: "cheeeeeeeerrrrrrrrr... and the crowd goes wild!" and everyone laughed and clapped. That made my day. I was rushed in the end and wasn't able to show my Northwind Virtual Earth demo but guess what?!! Jean-Rene, the organizer of DevTeach, needed to fill an extra slot this afternoon so I volunteered to do an entire session on "Conquering XML with LINQ in Visual Basic 9". I'm putting the deck together now and this will be a VERY fun session as well.... even without the beer! :-)

    The other totally awesome thing was that Sara Ford came up and sat on a panel to talk about Open Source with Richard Campbell and Carl Franklin. It will air on .NET Rocks! on Dec 6th. She was accompanied by our very own VB MVP Rod Paddock, and ASP.NET MVPs Shaun Walker from DotNetNuke Corp, and Rob Chartier. It was a great discussion and Richard opened up with one of the funniest computer nerd stories I ever heard.

    Enjoy! (And if you're here at the conference, come see my talk at 4:30pm!)

  • Beth Massi - Sharing the goodness

    First Day at DevTeach

    • 5 Comments

    I'm up in Vancouver at DevTeach and I have to say that so far it's been a great conference! I did a demo of my Visual Studio Tip of the Day browser and built an add-in (like I showed here) for part of the keynote with Ken Levy of the VSX team. This morning I open up VS and low and behold, Sara's next tip mentions my add-in and the conference! Weird, I'm reading about my add-in in my add-in :-).

    The TOTD browser is a great example of using LINQ to XML in Visual Basic so I encourage you to download it and have a look at how easy this was to do with LINQ. Also, Sara will be meeting me up here this evening for a panel discussion with Richard Campbell and Carl Franklin on Open Source. Thanks Sara! I owe you some good Canadian beer after the panel ;-).

    Yesterday I also did a session on migration strategies for VB6 apps to .NET. I talked about a decision framework and then showed a ton of code that demonstrated interop between VB6 and VB.NET using the Interop Forms Toolkit 2.0. I also showed a couple ways to approach debugging as well as showed how to deal with application config settings.

    I was surprised by how many people came to the talk and how well received it was. There's a lot of great VB developers here in Canada. If you're scratching your head about how to approach a migration project, please check out the Toolkit and these posts for more information.

    Later today I'm doing a session on What's New in Visual Basic 9 and it should be LOADS of fun. I have a few surprises planned :-).

  • Beth Massi - Sharing the goodness

    Visual Studio Tip of the Day - Let's Build an Add-In

    • 11 Comments

    Yesterday the VS Ecosystem team released the Visual Studio 2008 SDK 1.0 and the Visual Studio 2008 shell. The VS 2008 SDK contains full native Visual Basic support and contains many VB samples. What was in the VB Pack for the VS 2005 SDK is now included in the VS 2008 SDK, plus more.

    I've started playing with building Visual Studio Add-Ins in Visual Basic and it's really simple to get started. And what's really nice is you don't need to install the SDK to create Add-ins, they are built in. I've got the Tip of the Day Browser from Sara's rss feed running at startup now. Let's walk through how I did it in Visual Studio 2008. If you want to follow along here's the latest code for the Tip of the Day browser.

    First I added a new project to the current Solution. If you don't see your solution in the Solution Explorer, go to Tools --> Options and select "Projects and Solutions" and check the box "Always show Solution". Now right-click on the solution and select Add --> New Project, then expand "Other Project Types" and select "Extensibility" then choose "Visual Studio Add-In".

    This starts the Add-in wizard that helps you define some things about your add-in. The first step is to select your programming language so select "Create an Add-in using Visual Basic" and click next.

    Next step is to select the application hosts. For this example we'll uncheck "Visual Studio 2008 Macros" since I just want this to appear at startup and on the Tools menu.

    Next, type and name a description of your Add-in. For this example we'll set the name and description to "Visual Studio Tip of the Day".

    Next, the Wizard asks us how we want to invoke the Add-in. For this example we just want to be able to load it at start up of Visual Studio and provide a menu item in the Tools menu. Select the appropriate check boxes and click Next.

      

    The last thing the Wizard asks us is if we want an about box shown for our Add-in. For this example we'll skip this step so click Next and then Finish.

    This process adds a new Add-in project to your solution. Next open the Add-in project properties by double-clicking on My Project and go to the Compile tab and select the Advanced Options button at the bottom of the page. Then select the .NET Framework 3.5 as the target Framework.

    Next we'll need to add a reference to our Tip of the Day (SaraRssViewer) project. You can do this in the project properties --> References tab or you can right-click on the Add-in project and select Add Reference.

    Now that we have the references and target framework set up, open the Connect.vb file and in the OnStartUpComplete method we will write code to load the form:

    Public Sub OnStartupComplete(ByRef custom As Array) _

      Implements IDTExtensibility2.OnStartupComplete

     

        Dim frm As New SaraRSSViewer.Form1

        frm.Show()

    End Sub

    To run the form when the user selects our Add-in from the Tools menu, we'll need to put the same code to load the form into the Exec method at the bottom of the file:

    Public Sub Exec(ByVal commandName As String, _

                    ByVal executeOption As vsCommandExecOption, _

                    ByRef varIn As Object, ByRef varOut As Object, _

                    ByRef handled As Boolean) _

               Implements IDTCommandTarget.Exec

     

        handled = False

        If executeOption = vsCommandExecOption.vsCommandExecOptionDoDefault Then

            If commandName = "MyAddin1.Connect.MyAddin1" Then

     

                Dim frm As New SaraRSSViewer.Form1

                frm.Show()

     

                handled = True

                Exit Sub

            End If

        End If

    End Sub

    Last thing to do is set the Add-in project as the startup project so right-click on it and select "Set as Startup Project". Now hit F5 to compile and run. This will open up another instance of Visual Studio 2008 and you'll see the Tip of the Day window open:

    If you go to the Tools menu you'll also see the menu item there as well. You can customize the name of the menu item by changing the line of code in the OnConnection method of the Connect class that defines the command variable. Change the third parameter to specify the text to display on the menu item and the 4th to change the tooltip.

    Dim command As Command = _

        commands.AddNamedCommand2(_addInInstance, _

                                  "MyAddin1", _

                                  "Tip of the Day", _

                                  "Display the Visual Studio tips of the day", _

                                  True, 59, Nothing, _

                                  CType(vsCommandStatus.vsCommandStatusSupported, Integer) + _

                                  CType(vsCommandStatus.vsCommandStatusEnabled, Integer), _

                                  vsCommandStyle.vsCommandStylePictAndText, _

                                  vsCommandControlType.vsCommandControlTypeButton)

    When we build the Add-in it places an .addin file in your Visual Studio 2008\Addins\ folder which tells VS which Add-ins to load. As you can see, it's pretty easy to get a simple Visual Studio Add-in up and running. I encourage you to take a look at the other samples included in the SDK.

    In a future post we'll walk through how to deploy this Add-in to other machines.

    Enjoy,
    -B

  • Beth Massi - Sharing the goodness

    Visual Studio 2008 Released!

    • 17 Comments

    Early holiday gifts from Microsoft! Today we announced the release of Visual Studio 2008 and .NET Framework 3.5! Come and get it:

     Also check out the new redesigned Visual Basic Developer Center with more updated and dynamic content.

    Also, we'll be updating the Dev Center with more videos this week so stay tuned!

    Happy Holidays!

  • Beth Massi - Sharing the goodness

    Merging XML using Visual Basic 9

    • 8 Comments

    I made some modifications to my Visual Studio Tip of the Day browser application I created last week. There I am downloading the RSS feed from Sara's blog and saving it to disk so that I only retrieve the next tip every 24 hours. However, the RSS only returns the last 15 posts so instead of completely replacing the cached feed on disk I want to merge the old tips from the cache file into the downloaded rss feed so that the older tips are preserved. This is really easy using a LINQ to XML query. 

    If My.Settings.CacheFile = "" Then

                My.Settings.CacheFile = _

           Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) & "\tiprss.xml"

    End If

     

    Dim file = My.Computer.FileSystem.GetFileInfo(My.Settings.CacheFile)

    'Only load from the web once per day, else load from the cache

    If Not file.Exists OrElse file.LastWriteTime.Date < Now.Date Then

     

          Me.Feed = XDocument.Load(My.Settings.TipsURI)

     

          If file.Exists Then

              'Put the old items from the cache into the new feed.

              Dim cache = XDocument.Load(My.Settings.CacheFile)

     

              Dim oldItems = From cacheItem In cache...<item> _

                             Group Join item In Me.Feed...<item> _

                                 On cacheItem.<guid>.Value Equals item.<guid>.Value _

                                 Into Count() _

                             Where Count = 0 _

                             Select cacheItem

     

              Dim items = Me.Feed...<item>

              Dim lastitem = items(items.Count - 1)

              lastitem.AddAfterSelf(oldItems)

          End If

     

          Me.Feed.Save(My.Settings.CacheFile)

    Else

          Me.Feed = XDocument.Load(My.Settings.CacheFile)

    End If

    Notice that all I'm doing here is selecting the old tips from the cache feed by using a group join to the new feed where the count of items in the group is 0. This is similar to the syntax NOT IN(subquery) in T-Sql. This will return any items in the cache feed that do not already exist in the new feed. (I also updated the location of the cache based on community feedback so it would be Vista friendly.) I updated the sample here.

    Enjoy!

  • Beth Massi - Sharing the goodness

    Visual Basic WPF Samples - The Concept of Content

    • 2 Comments
    If you missed Young's post on the VB Team blog, he has started helping Patrick convert all the samples from Charles Petzold's WPF book (Applications = Code + Markup). Evan Lim who currently teaches WPF & Blend courses at Foothill Community College in Los Altos CA with Cal Schrotenboer, has also offered to help! This set of samples are for Chapter 3.
  • Beth Massi - Sharing the goodness

    Channel 9 Interview: Type Inference in Visual Basic with Bill Horst

    • 1 Comments
    I just posted an interview on Channel 9 with Bill Horst, a member of the Visual Basic QA team. Bill shows us the ins and outs type inference in the newest version of Visual Basic in Visual Studio 2008. He shows us how the new Option Infer works and how various types are infered by the compiler without having to explicitly declare them. Type inference is one of the new features in Visual Basic to support LINQ.

    Also make sure to check out these LINQ How-Do-I videos on the VB Dev Center.

    Enjoy!
  • Beth Massi - Sharing the goodness

    Visual Studio Tip of the Day Browser

    • 10 Comments

    I'm sitting here with writer's block on an article I'm supposed to be writing so in order to coax the technical writing muse I decided to write an application I've been meaning to do for over a month. If you didn't know, on Sara's blog she has a category called Visual Studio Tip of the Day where she posts little VS gems. I wanted to be able to easily search by my own keywords through all the tips she's posted so far so I figured it would be a simple LINQ to XML query to do it. I was right.

    First I added the RSS schema using the XML to Schema new item template and pointed it to her blog's RSS feed. This added the RSS schema information (.xsd files) to my project in order to enable XML IntelliSense. Next I created a class called Tip that simply contains the properties that I was interested in from the feed; Published, Link, Title and Text.

    Public Class Tip

     

        Private m_link As String

        Public Property Link() As String

            Get

                Return m_link

            End Get

            Set(ByVal value As String)

                m_link = value

            End Set

        End Property

     

     

        Private m_title As String

        Public Property Title() As String

            Get

                Return m_title

            End Get

            Set(ByVal value As String)

                m_title = value

            End Set

        End Property

     

     

        Private m_date As Date

        Public Property Published() As Date

            Get

                Return m_date

            End Get

            Set(ByVal value As Date)

                m_date = value

            End Set

        End Property

     

     

        Private m_text As String

        Public Property Text() As String

            Get

                Return m_text

            End Get

            Set(ByVal value As String)

                m_text = value

            End Set

        End Property

     

    End Class

    Next I loaded up an XDocument from her feed and started to write my query. What I want to end up with is a collection of my Tip objects I defined above. To do this, in your Select clause you use the syntax "Select New ClassName With {", like this:

    Dim Feed = XDocument.Load("http://blogs.msdn.com/saraford/rss.xml")

    Dim searchTerm = "*" & Me.TextBox1.Text.ToLower & "*"

     

    'This is the fun part. Select the tips we want from Sara's rss feed.

    ' This query creates a collection of our Tip class.

    Dim tips = _

             From item In Feed...<item> _

              Let Published = CDate(item.<pubDate>.Value).ToLocalTime _

              Let Title = item.<title>.Value _

              Let Link = item.<link>.Value _

              Let Text = item.<description>.Value _

              Let Category = item.<category>.Value _

             Where Category IsNot Nothing AndAlso _

                   Category.ToLower Like "*tip of the day*" AndAlso _

                  (Title.ToLower Like searchTerm OrElse _

                   Text.ToLower Like searchTerm) _

             Order By Published Descending _

             Select New Tip With _

              {.Published = Published, _

              .Title = Title, _

              .Link = Link, _

              .Text = Text}

    I've got a textbox on the form that I'm using to type in keywords to search through the titles and the text of all the posts in the feed. I use .ToLower so that the keyword search is case insensitive. Now that we have a collection of our Tip objects we can easily bind this to a DataGridView and display the selected tip's text (which is the description in the RSS) inside a WebBrowser control for instance.

    Notice here, I typed the keyword "editor" and it found posts with both editor in the title and the description text. I've put the application into Code Gallery for you to play with. It does a couple additional things (unrelated to the LINQ query) like stores the URI in My.Settings, loads the rss feed only once per day (otherwise it loads from a cache file), as well as loading on a background thread so not to block the UI. You can also click on the hyperlink below the grid to navigate the WebBrowser to the actual post so you can add/view the post comments online.

    Enjoy!

  • Beth Massi - Sharing the goodness

    I'm Speaking at DevTeach Nov 26th - 30th

    • 0 Comments

    I'll be speaking at DevTeach in Vancouver November 26th - 30th. This is a great conference that I've been speaking at for a few years. Normally in Montreal (in the Spring), they're starting to hit the other major Canadian cities. The level of speakers is amazing and they have .NET, Agile, Architecture, SQL, and XNA tracks. I'll be speaking on Visual Basic, LINQ, XML, and Interop w/ VB6. Check out the sessions here.

    I'll also be speaking at QCon this week. My session is Friday so check it out if you're in SF!

    Enjoy!

     

Page 1 of 2 (14 items) 12