April 27, 2002

FormatSize – Format a size expressed in bytes

‘ Returns a formatted string that shows the size in Bytes, KBytes or MBytes’ according to the size’ Usage:’ Dim ProperSizeString As String = FormatSize(“132100842”)’ -> returns “125.98 MB”Function FormatSize(ByVal SizeInBytes As Double) As String If SizeInBytes < 1024 Then Return String.Format("{0:N0} B", SizeInBytes) ElseIf SizeInBytes < 1024 * 1024

StringToCode – Convert a string to the corresponding VB code

‘ Put quotes around a string and double any embedded Chr$(34)” convert all control characters into ControlChars.*** VB constants’ or CHR() functions” This function is useful, for example, when you are writing a MsgBox wizard. ‘ Tipically, such a wizard would let the user enter a string in a multiline

CompareValue – Check whether a value is in a list of values

‘ Compares a numeric or string value with a list of other values.’ Returns the 1-based index of the matching value, or zero if the’ value doesn’t appear in the list.’ String comparisons are case-sensitive.” This function can conveniently replace a Select Case or a list’ of ORed comparison, e.g.