June 8, 2002

AddBackslash – Append a backslash to a path if needed

‘ Append a backslash (or any character) at the end of a path’ if it isn’t there alreadyFunction AddBackslash(ByVal Path As String, Optional ByVal ch As Char = “”c) _ As String If Not Path.EndsWith(ch) Then AddBackslash = Path & ch Else AddBackslash = Path End IfEnd Function

ChangeFileExtension – Modify the extension in a file name

‘ Change the extension of a file name’ if the last argument is True, it adds the extension even if the file doesn’t ‘ have oneFunction ChangeFileExtension(ByVal FileName As String, _ ByVal Extension As String, Optional ByVal AddIfMissing As Boolean = False) _ As String If AddIfMissing OrElse IO.Path.GetExtension(FileName).Length >

Hiding pages of a TabControl

Sometimes you may need to hide or show some pages of a TabControl according to the information you want to show, basing on the currently logged-in user for example (users with low privileges won’t be able to get all the information or to change records). To do this, you may

Creating owner drawn menu items to simulate a color picker

‘ This class does the owner drawing of a MenuItem to draw a color box.’ The class inherits from MenuItem, thus the ColorMenuItem objects’ can be added to a parent MenuItem or a context menu as you ‘ normally do, and can also be mixed with other MenuItem items ‘

Ensuring that a style is supported by a font family

‘ Not all fonts support the same styles. This function takes in ‘ input a font family and a font style, and returns a font style’ which is safe for that particular font family, by removing’ the styles that are not supported” Example:’ GetSafeStyleForFontFamily(richTextBox1.SelectionFont.FontFamily,’ ‘ richTextBox1.SelectionFont.Style)Public Function GetSafeStyleForFontFamily(ByVal fontFam As