PRJ AppNote: Constants for Project and Visual Basic (WP1043)Last reviewed: November 24, 1997Article ID: Q124131 |
The information in this article applies to:
The "Using Visual Basic and Microsoft Project Constants with Visual Basic Standard or Professional Edition" Application Note is now available from Microsoft Product Support Services. This Application Note includes the files that contain global declarations for the Microsoft Project and Visual Basic, Applications Edition, constants. You can obtain this Application Note from the following sources:
THE TEXT OF WP1043
Microsoft(R) Product Support Services Application Note (Text File) WP1043: USING VISUAL BASIC(R) AND MICROSOFT PROJECT CONSTANTS WITH VISUAL BASIC STANDARD OR PROFESSIONAL EDITION Revision Date: 12/94 1 DiskThe following information applies to Microsoft Project for Windows(TM), version 4.0.
--------------------------------------------------------------------- | INFORMATION PROVIDED IN THIS DOCUMENT AND ANY SOFTWARE THAT MAY | | ACCOMPANY THIS DOCUMENT (collectively referred to as an Application | | Note) IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER | | EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED | | WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR | | PURPOSE. The user assumes the entire risk as to the accuracy and | | the use of this Application Note. This Application Note may be | | copied and distributed subject to the following conditions: 1) All | | text must be copied without modification and all pages must be | | included; 2) If software is included, all files on the disk(s) must | | be copied without modification (the MS-DOS(R) utility diskcopy is | | appropriate for this purpose); 3) All components of this | | Application Note must be distributed together; and 4) This | | Application Note may not be distributed for profit. | | | | Copyright (C) 1994 Microsoft Corporation. All Rights Reserved. | | Microsoft, MS-DOS, and Visual Basic are registered trademarks and | | Windows is a trademark of Microsoft Corporation. | --------------------------------------------------------------------- OVERVIEWThis Application Note includes the following files, which contain global declarations for the Microsoft Project and Visual Basic, Applications Edition, constants:
You can open and print these files using any text editor and then use the printouts as references when you write code. The files list the names of all the constants along with their numeric values.
WHY USE BUILT-IN CONSTANTS?When you create Visual Basic procedures in Microsoft Project, you can use constants to represent values that you use frequently. Using constants makes your code easier to read and easier to maintain. For example, if you use the value 8h frequently, you can define a constant called <myvalue>, and then use <myvalue> in your procedure everywhere you would use the value 8h. If you change the value of <myvalue>, you only have to make the change in one location instead of in each place you used the value 8h. Microsoft Project and Visual Basic, Applications Edition, have built- in constants that are used with functions, methods, objects, and properties. The Microsoft Project built-in constants all begin with the letters "pj," and the Visual Basic, Applications Edition, built-in constants begin with the letters "vb." When you use built-in constants, your Visual Basic code is easier to read because built-in constants describe the functions they perform. For example, to change the alignment of the text in a column, you could use the following Visual Basic code:
ColumnAlignment Align:=pjCenterThe built-in constant, pjCenter, is easier to remember than the numeric value it represents. Without using the Microsoft Project built- in constant, the line above would appear as follows:
ColumnAlignment Align:=1Note how much more intuitive this line of code is when it contains the built-in constant name.
USING BUILT-IN CONSTANTS WITH VISUAL BASIC PROFESSIONAL OR STANDARD EDITIONTo use these constants in the Standard or Professional Editions of Visual Basic, you must declare them. In most cases, you will want to declare them globally by loading them into a code module. If you want to limit the scope of the constants to a form or procedure, change the Global declaration to Const, and paste only the constants you want to use in the Declaration section of the form or procedure. To load PJCONST.BAS or VBACONST.BAS into a code module:
WHERE ARE BUILT-IN CONSTANTS LISTED IN MICROSOFT PROJECT?If you want to know which built-in constants are available for a particular function, method, object, or property, search in the Visual Basic Reference in Microsoft Project Help for the item you're looking for or use the Object Browser to view a list of built-in constants. To use Help to see which built-in constants are available for a particular item:
To look up constants using the Object Browser:
TO OBTAIN THIS APPLICATION NOTE
You can find WP1043.EXE (size: 21263 bytes) , a self-extracting file, on the followingservices:
ARTICLE-ID: Q119591 TITLE : How to Obtain Microsoft Support Files from Online Services
http://www.microsoft.com/worldwide/default.htm Keywords : kbappnote kbcode kbprg Version : 4.00 Platform : WINDOWS Issue type : kbinfo |
================================================================================
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |