Visual Basic

Retrieve File Version Information

Win32 file images can contain a file version resource that stores product and version information about the file. The version num-ber is actually four 16-bit values typically displayed using dot notation (such as 4.0.9.4566). You can use this information when determining whether one file is newer or older than another.

Testing a Business Rule Should Not Have Any Side Effects

Testing a business rule should have no side effects. Avoid err.raise and msgboxes inside business rule tests.Consider this example: public const kMinimumApplicantAge = 18 ‘declared in common modPublic Function IsApplicantAgeEligible(DOB as date, testDate as date) asboolean If datediff(

An Efficient Method of Creating Lists For Month Names

The following code is an efficient, flexible, system-setting-independent procedure. MonthNames is either a listbox or a combobox. If StartMonth is greater than EndMonth, the list of month names will be generated in the reverse order. Sub LoadMonthNames(MonthNames As Object, _Optional NameFormat As String =

Suspending a Monitor Into the Powersave State

If you find the need to put the monitor into rest, you can do so using the following example: Create an standard EXE project Add a CommandButton to Form1 Insert the following lines of code into Form1: Private Const SC_MONITORPOWER = &HF170& Private Const WM_SYSCOMMAND = &H112& Private Declare Function

ArrayMin – The value and index of lowest element in an array of any type

‘ Return the minimum value in an array of any type” FIRST and LAST indicate which portion of the array’ should be considered; they default to the first’ and last element, respectively’ If MININDEX is passed, it receives the index of the’ minimum element in the arrayFunction ArrayMin(arr As Variant,

Designing Extended Multi-Select List Boxes

While designing a database in Access 2000 recently, I decided the most intuitive way for my users to be able to look at the data they wanted was to let them use extended multi-select list boxes to pick the information they wanted. The function below converted their selections into a

Simple Component Testing

When creating ActiveX components, an easy way to test them is to add a module to the project (see the code below). In this module you can write methods that will instantiate your component and then call the methods. To make sure nothing was broken, you can keep your unit

SetExternalHTMLEditor – Change the name of the external HTML editor

Const HKEY_LOCAL_MACHINE = &H80000002′ modify the name and path of the external HTML editor’ configured in the Tools|Options|Advanced tab” Changes apply immediately (no need to restart VB)” Requires the SetRegistryValue functionSub SetExternalHTMLEditor(ByVal editorFileName As String) SetRegistryValue HKEY_LOCAL_MACHINE, _ “SoftwareMicrosoftVisual Basic6.0External Tools”, “HTML Editor”, _ editorFileNameEnd Sub

CheckMathProcessor – Check whether a math processor is installed

Const HKEY_LOCAL_MACHINE = &H80000002′ Return True if the system has a math processor” Requires the CheckRegistryKey routineFunction CheckMathProcessor() As Boolean ‘ if a math processor exists, Windows creates ‘ the following Registry key CheckMathProcessor = CheckRegistryKey(HKEY_LOCAL_MACHINE, _ “HARDWAREDESCRIPTIONSystemFloatingPointProcessor”)End Function

No more posts to show