IsAuthor - October 1998 - August 2006

While developing software it is sometimes useful to include code that only executes if the application is being run by the 'Author'.  Some years ago I wrote a function that examines environment variable 'Author' and if it is any author the function returns True. Then I can do something like:

If IsAuthor() = 2 Then
    .... do my stuff
End If

2006/08/09  - A VB 2005 version of IsAuthor is added. See below to download that version.

Some Uses

    1. Open a Test Database
    2. Show Progress Information in the Form's Caption
    3. Skip Startup Code and Jump Into Code to Be Tested
    4. Set Test Variables
    5. Test Your Unique Code While Sharing Development With Others

Setting the Author Environment Variable in Windows 95/98

Add 'Set Author = yourname' to AutoExec.Bat, for example:

env95.gif (2343 bytes)

Setting the Author Environment Variable in Windows NT

Right click on 'My Computer'. Select 'Properties'. Select tab 'Environment'. Enter variable 'Author' and value 'yourname', click Set, for example:

envnt.gif (8578 bytes)

Demo Application

I wrote a VB4 application to demonstrates the routines. It returns 'true' if any author is defined. The sample:

demo.gif (3432 bytes)

Using the IsAuthor Function


If IsAuthor() Then 'do any author's stuff
If IsAuthor() = 3 Then 'do donaldduck's stuff

Dim vntAuthor As Variant
If IsAuthor(vntAuthor) Then 'get the name
if any

Compiler Variable 'EnableIsAuthor'

You must set compiler variable 'EnableIsAuthor = 1' to use the routine. If desired, set 'EnableIsAuthor = 0' before compiling a production version of your application to disable the IsAuthor function.

Help Uses modConnectToWebSite

The demo program uses modConnectToWebSite.bas to display this page. You do not need to include it in your application. For details on the use of that module click here.

Include in Your Application

You will need to add the following module to your application if you want to use this function:

modIsAuthor.bas The routine described in this document.

VB 2005 Version

Download VB Code

Click here to download the VB 4 Source Code [4k]. The demo was written using VB4. You could load it using VB5 or VB6.

Click here to download the VB 2005 Source Code [31k].

Previous Tip    Tip Index    Next Tip


Updated 2006/08/09