> ## Content Index
> Fetch the complete content index at: https://nolongerset.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# Beautiful Blocks of Boilerplate
- URL: https://nolongerset.com/beautiful-blocks-of-boilerplate/
- Published: 2021-05-04T00:01:06.000Z
- Updated: 2026-05-08T13:04:53.000Z
- Description: Using the colon character to join multiple lines of code all willy-nilly can lead to messy code. But, used judiciously, it can create beauty from chaos.
- Author: Mike Wolfe
- Tags: Conventions, Hidden Features, #Import 2026-05-20 02:59

In my article, [The ArrowKeyNav Routine](https://nolongerset.com/arrowkeynav-routine/), I presented a Sub that you can use to override the default handling of the up and down arrow keys on a continuous form. The problem with the routine as I presented it is that you need to call it from every control where you want to override the arrow key functionality.

Here's what that might look like in a form module:

```vba
Private Sub cbSupplierID_KeyDown(KeyCode As Integer, Shift As Integer)
    ArrowKeyNav KeyCode, Shift
End Sub

Private Sub chkDiscontinued_KeyDown(KeyCode As Integer, Shift As Integer)
    ArrowKeyNav KeyCode, Shift 
End Sub

Private Sub tbID_KeyDown(KeyCode As Integer, Shift As Integer)
    ArrowKeyNav KeyCode, Shift
End Sub

Private Sub tbListPrice_KeyDown(KeyCode As Integer, Shift As Integer)
    ArrowKeyNav KeyCode, Shift
End Sub

Private Sub tbProductCode_KeyDown(KeyCode As Integer, Shift As Integer)
    ArrowKeyNav vbKeyDown, Shift
End Sub

Private Sub tbProductName_KeyDown(KeyCode As Integer, Shift As Integer)
    ArrowKeyNav KeyCode, Shift
End Sub
```

There are a couple of ways to reduce the amount of boilerplate code we need in this situation, but we're going to set that aside for the purposes of this article. So, for the sake of argument, let's just assume that there's no way to reduce the amount of code. Given that constraint, how can we increase the readability of the above code?

### Joining lines of code with the colon character

We can join multiple lines of code using the [colon character](https://docs.microsoft.com/en-us/openspecs/microsoft%5Fgeneral%5Fpurpose%5Fprogramming%5Flanguages/ms-vbal/7ef9ae86-dfdb-47f1-b53b-ef0c2ea9f8ed) (`:`).

> <EOS> is used as a terminal element of the syntactic grammar to name the *token* that acts as an "end of statement" marker. In general, the end of statement is marked by either a <LINE-END> or a **colon character**.

### Improving readability by joining lines

This technique is something you need to use with care. But, if used judiciously, it can increase the readability of your code. 

In the sample code above, each Sub calls the same exact code: 

```vba
ArrowKeyNav KeyCode, Shift
```

Actually, that's not true. If you look closely, you will see that the `tbProductCode_KeyDown()` routine passes `vbKeyDown` instead of `KeyCode` as the first argument.

This difference is easy to miss using standard VBA formatting, though:

![](https://storage.ghost.io/c/eb/d7/ebd732c1-5f03-4f07-b386-5d08557e15c9/content/images/2021/05/image-7.png)

Where's Waldo? Can you spot the inconsistent routine call in the above code?

### [Making wrong code look wrong](https://www.joelonsoftware.com/2005/05/11/making-wrong-code-look-wrong/)

If we join the lines using colons–and adjust the whitespace so all of our calls to `ArrowKeyNav` are left-aligned–then the inconsistency that blends in above stands out like a sore thumb in the code below:

![](https://storage.ghost.io/c/eb/d7/ebd732c1-5f03-4f07-b386-5d08557e15c9/content/images/2021/05/image-8.png)

There's Waldo! I knew something wasn't quite right with that misaligned End Sub.

When viewed in the context of normal functions and subroutines, our block of boilerplate code clearly stands apart. This distinction helps increase the [signal to noise ratio](nolongerset.com/signal-vs-noise/) of our code:

![](https://storage.ghost.io/c/eb/d7/ebd732c1-5f03-4f07-b386-5d08557e15c9/content/images/2021/05/image-9.png)

It takes very little cognitive processing power to ignore that block of boilerplate code when reading this module. That's a good thing.

*Image by [Alexander Stein](https://pixabay.com/users/alexanderstein-45237/?utm%5Fsource=link-attribution&utm%5Fmedium=referral&utm%5Fcampaign=image&utm%5Fcontent=169631) from [Pixabay](https://pixabay.com/?utm%5Fsource=link-attribution&utm%5Fmedium=referral&utm%5Fcampaign=image&utm%5Fcontent=169631)*