Attempted to Read or Write Protected Memory

I’ve been working on switching over to a “new” machine (more on that in a new post). In the process my time card program stopped working with the following error: System.AccessViolationException was unhandled Message: Attempted to read or write protected memory. This is often an indication that other memory is corrupt. Unfortunately this error doesn’t show up until well after it occurs. So you need to make some educated guesses as to where it is coming from. [Read More]

Excel Queries

I came across some nice libraries to use while programming to query Excel. Right now I’m am using the standard COM interface for my projects, which is fine for small ranges (which is true for most users – I would assume). But for large ranges I would need something more powerful. LinqToExcel LinqToExcel appears to be a great project for using a Linq interface to query Excel (but not write to Excel). [Read More]

XML Comments

Comment headers above procedures can be convenient when you want to know what a function does and what the parameters are for – especially if they weren’t named with enough description. Luckily Visual Studio provides a way to do these comments easily and it gives you intellisense for your own functions! They are called XML comments. All you need to do is put in three comment markers (‘) and then it will fill in everything for you (if you already have the procedure/parameters filled in). [Read More]

Algorithm Resources

Introduction I was reading through Code Complete a classic coding book that is widely considered one of the best practical guides to programming, Steve McConnell’s original CODE COMPLETE has been helping developers write better software for more than a decade. And he mentioned algorithm books. What, there exists algorithm books? You mean I don’t need to come up with this code all by myself? Combined with the internet to figure out what exactly these algorithms are called, they could be a huge help. [Read More]

Generic Types

Last time we went over Overloading function in .NET. Today we’ll take a look at generics. I had been wondering how to do this for some time, seeing that I could do it with Microsoft’s built in code. I have to say, it is pretty nice and really makes coding much easier and cleaner. A generic type is a single programming element that adapts to perform the same functionality for a variety of data types. [Read More]

Overloading in VB.NET

In previous posts I showed how you can use Extensions and Lambda Expressions to make some pretty versatile functions in .NET. Today I’ll show a method that really helps for the readability and organization of your code. In the past we used optional parameters to make a function do multiple things. We even needed to make new functions that did pretty much the same thing in order to make it better organized. [Read More]

Lambda Expressions

An Introduction

Another thing that I like about programming in .NET beyond LINQ and Extensions is lambda expressions. (It should be noted that LINQ, Extensions, and lambda expressions are all related). Lambda expressions are “are callable entities that are defined within a function, you can return a lambda expression from a function and you can pass lambda expressions to other functions.” Lambda expressions come with the System.Core library, so no need to add a reference nor Imports at the top of your class. [Read More]

Linq: An Introduction

Another thing that I like about programming in VB.NET beyond Extensions is LINQ. LINQ is similar to SQL in structure - which is “a declarative programming paradigm that expresses the logic of a computation without describing its control flow.” So LINQ takes declarative paradigm and applies it to object oriented programming. What’s so great about this? Well, it does slow the program down, but it speeds up the the programming process, puts the information in a form that is more descriptive (although that is no excuse not to thoroughly comment your code), and makes programming easier. [Read More]

Extensions in VB.NET

Learning how to use VB.NET can be quite the leap from VBA, but once you start learning VB.NET and have much more control it’s difficult to want to go back to VBA. One of the things that I like about VB.NET is methods. Extensions allow you to extend data type methods. So, let’s say you have a String data type (Strings in VB.NET are like a class in and of themselves) and you want it to have the method of appending “]” at the end. [Read More]