Microsoft Office 2010 Engineering
The official blog of the Microsoft Office product development group

Browse by Tags

  • Blog Post: Functional Programming Tutorial for Visual Basic 9.0

    Visual Basic 9.0 added many language features that allow us to write in the functional style in a natural and expressive way. The value of programming in the functional style has been apparent to me for some time. VB developers can realize the benefits of functional programming, so I’ve written...
  • Blog Post: Complete Listing of ParseWordML - VB

    [Table of Contents] [Next Topic] The following code is attached to this page. This blog is inactive. New blog: EricWhite.com/blog Blog TOC Imports System.IO Imports System.Xml Imports System.Text Imports DocumentFormat.OpenXml.Packaging Public Class GroupOfAdjacent( Of TElement, TKey) Implements...
  • Blog Post: Conclusion - VB

    [Table of Contents] If you finished this tutorial, feel free to add a comment on this page. This blog is inactive. New blog: EricWhite.com/blog Blog TOC In the end, I believe that programming in the FP style is useful and powerful. When programming, it enables you to focus more on the problem...
  • Blog Post: Retrieving the Two Code Groups - VB

    [Table of Contents] [Next Topic] There are two groups of paragraphs in our document that are styled as "Code". The first group contains the C# code that we want to test. The second group contains a single paragraph that is the output of the code in the first group. Next in the process of formulating...
  • Blog Post: Filtering Out the Groups that we Don't Want - VB

    [Table of Contents] [Next Topic] We are not interested in the groups that don’t contain code, so let's get rid of them. To do this, we simply tack a call to the Where operator on the end: This blog is inactive. New blog: EricWhite.com/blog Blog TOC Dim groupedCodeParagraphs = paragraphsWithText...
  • Blog Post: The Final Results - VB

    [Table of Contents] [Next Topic] We need one more query to retrieve the comments: This blog is inactive. New blog: EricWhite.com/blog Blog TOC Dim defaultStyle As String = _ CStr ( _ ( _ From style In styleDoc.Root _ .Elements(w + "style" ) _ Where ( _ CStr (style.Attribute(w + "type" )) = ...
  • Blog Post: Refactoring using a Pure Function - VB

    [Table of Contents] [Next Topic] It would be useful to refactor this example to clean up the code that determines the style of the paragraph. We can make a function that has no side effects that returns the style name: This blog is inactive. New blog: EricWhite.com/blog Blog TOC Public Function...
  • Blog Post: Retrieving the Default Style Name from the Styles Part - VB

    [Table of Contents] [Next Topic] There is a problem in the example presented in the previous topic, which is that it sets the Style property of the anonymous type to null if there is no style on the paragraph. This is incorrect; we should use another query to find the default style in the styles part...
  • Blog Post: Retrieving the Text of the Paragraphs - VB

    [Table of Contents] [Next Topic] Our next goal is to retrieve the text of the paragraphs in the document. Text is stored in the "t" nodes that are contained in "r" nodes that are children of the paragraph node. Text may be broken up into multiple "t" nodes, so we have to concatenate all of the text...
  • Blog Post: The Source Open XML Document - VB

    [Table of Contents] [Next Topic] Attached to this page is the source Open XML word document that contains the paragraphs styled as Code. This blog is inactive. New blog: EricWhite.com/blog Blog TOC The document looks like this: Following is the XML for the main document part. You can see...
  • Blog Post: Printing the Parts of an Open XML Document - VB

    [Table of Contents] [Next Topic] An easy way to see the XML in the parts of a WordprocessingML document is to create one in your word processor, save it, and then run the following program that prints the XML to the console. You can also rename the file, adding a ".zip" to the end, and then extract...
  • Blog Post: Using the Open XML SDK - VB

    [Table of Contents] [Next Topic] Open XML Packages To follow this tutorial, you don't need to delve into all of the details of working with packages. This topic presents a small chunk of code that you can use as boilerplate code – it opens a word document and retrieves the main part, the...
  • Blog Post: Retrieving the Paragraphs - VB

    [Table of Contents] [Next Topic] Our first goal is to retrieve all paragraphs in the document, along with the style of the paragraph. This blog is inactive. New blog: EricWhite.com/blog Blog TOC To review, all paragraphs are children of the "body" element, and have a tag of "w:p". If the style...
  • Blog Post: Programming in a Functional Style - VB

    [Table of Contents] [Next Topic] We're now ready to talk more about some of the core FP concepts. Declarative vs. Imperative Code This blog is inactive. New blog: EricWhite.com/blog Blog TOC Imperative languages are state based. Object-oriented programming languages such as C#, C++, and Java...
  • Blog Post: Parsing XML from an Open XML Document - VB

    [Table of Contents] [Next Topic] The first problem that we're going to tackle is to retrieve some specific text out of an Open XML Word document. In this word document will be text that has the style of "Code". We want to find all consecutive paragraphs that have this style, and retrieve the paragraph...
  • Blog Post: Aggregation - VB

    [Table of Contents] [Next Topic] There are many times when composing queries that you have to do aggregation. There are a number of built-in aggregators: This blog is inactive. New blog: EricWhite.com/blog Blog TOC · Count · LongCount · Sum · Min ·...
  • Blog Post: Grouping - VB

    [Table of Contents] [Next Topic] LINQ query expressions look a lot like SQL, and that is intentional. SQL is a non-procedural query language that many developers are already familiar with, so to the extent that LINQ looks like SQL, it gives developers a familiar frame of reference. This blog is...
  • Blog Post: Pure Functions - VB

    [Table of Contents] [Next Topic] FP introduces the notion of pure functions. A pure function is one that doesn't affect the state of anything outside of it, nor depends on anything other than the arguments passed to it. Also, given a set of arguments, a pure function will return the same result. ...
  • Blog Post: Using Nominal Types for Tuples - VB

    [Table of Contents] [Next Topic] The following example (from the previous topic on anonymous types) shows projection of a collection of anonymous types: This blog is inactive. New blog: EricWhite.com/blog Blog TOC Dim custList() As Customer = { _ New Customer With { _ .Name = "Bob" , _ .Address...
  • Blog Post: Implementing Iterators - VB

    [Table of Contents] [Next Topic] This topic on iterators discusses the yield return feature of C#, and its implications to us when writing Visual Basic code in the functional style. Visual Basic doesn’t have a feature that corresponds to yield return, but there are several ways to work around...
  • Blog Post: Lazy Evaluation (and in contrast, Eager Evaluation) - VB

    [Table of Contents] [Next Topic] One of the most important concepts in LINQ is the notion of lazy evaluation. Without this facility, LINQ would perform very poorly. Query expressions operate on some type that implements IEnumerable(Of T). The variable of type IEnumerable(Of T) on which the query...
  • Blog Post: Deferred Execution - VB

    [Table of Contents] [Next Topic] Deferred execution is a topic related to lazy evaluation, but it is a topic worth discussing in its own right. This blog is inactive. New blog: EricWhite.com/blog Blog TOC In the previous topic, we saw this code as an example of lazy evaluation (once again, the...
  • Blog Post: Object and Collection Initializers - VB

    [Table of Contents] [Next Topic] Object are a VB 9.0 feature that allows you to create objects in an expression context instead of in a statement context. Sometimes this is called in-line initialization of objects. When doing FP, we want to create tuples (next topic), and we sometimes want to use...
  • Blog Post: Projection

    [Table of Contents] [Next Topic] Projection is the abstraction of taking one shape of data and creating a different shape of it. For instance, you could take a collection of one type, filter it and/or sort it, and then project a collection of a new type. This blog is inactive. New blog: EricWhite...
  • Blog Post: Tuples and Anonymous Types - VB

    [Table of Contents] [Next Topic] Anonymous types are a way that you can define, declare, and instantiate a type and an object in a single step. Selection in a LINQ query expression is an operation of projection. While projecting, you often want to create new types that are used only in the context...
Page 1 of 2 (35 items) 12