Microsoft Knowledge Base Article
This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved.
Terms
of Use |
Trademarks
Article ID: 163009 - Last Review: July 3, 2008 - Revision: 5.0
DOC: Values for Scripting Object Constants Defined
This article was previously published under Q163009
We strongly recommend that all users upgrade to Microsoft Internet Information Services (IIS) version 7.0 running on Microsoft Windows Server 2008. IIS 7.0 significantly increases Web infrastructure security. For more information about IIS security-related topics, visit the following Microsoft Web site:
For more information about IIS 7.0, visit the following Microsoft Web site:
The version of VBScript (VBS) provided with Active Server Pages currently
does not have access to the values of constants defined by the Scripting
object. As a result, you must provide a definition of the constants you
wish to use in your scripts. Because the documentation does not provide the
values for these constants, it can be difficult to determine what the
numerical value is for a given constant.
Consider the following code example:
Set fs = Server.CreateObject("Scripting.FileSystemObject")
Set a = fs.OpenTextFile("c:\testfile.txt", ForAppending, FALSE)
If you cut and paste this code into an .asp file, you get the following
error because VBS doesn't recognize "ForAppending":
Microsoft VBScript runtime error '800a0005'
Invalid procedure call or argument: 'fs.OpenTextFile'
The best approach is to use a server-side include file to provide a
definition of the constants for your script. This is similar to using the
Adovbs.inc or Adojavas.inc files provided with ADO.
Here is a list of the values of the most commonly used constants for the
Scripting object:
iomode- ForAppending = 8
- ForReading = 1
- ForWriting = 2
format- TristateFalse = 0
- TristateMixed = -2
- TristateTrue = -1
- TristateUseDefault = -2
These are determined by viewing the Microsoft Scripting Runtime type
library, contained in Scrrun.dll, in the Visual Basic Object Browser.
To provide an include file that defines these values, paste the text below
into a file called Filevbs.inc, and save it to a virtual root. Then add an
include directive, similar to the one below, to the ASP file that needs to
access the definitions of these constants.
<!--#include virtual="http://support.microsoft.com/ASPSAMP/SAMPLES/FILEVBS.INC"-->
(Save the text below to file: Filevbs.inc)
<%
'----------------------------------------------
'
' FileSystemObject constants include file for VBScript
'
'----------------------------------------------------->
'---- iomode Values ----
Const ForAppending = 8
Const ForReading = 1
Const ForWriting = 2
'---- format Values ----
Const TristateFalse = 0
Const TristateMixed = -2
Const TristateTrue = -1
Const TristateUseDefault = -2
%>
An alternative approach is described in the following Microsoft Knowledge Base article:
261250Â
(http://kbalertz.com/Feedback.aspx?kbNumber=261250/EN-US/
)
HOWTO: Expose and Use ENUMS from Visual Basic Components in Active Server Pages
For the latest Knowledge Base articles and other support information on
Visual InterDev and Active Server Pages, see the following page on the
Microsoft Technical Support site:
APPLIES TO
- Microsoft Active Server Pages 4.0
- Microsoft Internet Information Server 4.0
- Microsoft Internet Information Services 5.0
| kbdocfix kberrmsg KB163009 |
Community Feedback System
Very often, it takes hours to solve a problem. Very often, you've looked high
and low, and have tried a lot of solutions. When you finally found it, chances
are, it was because someone else helped you. Here's your chance to give back.
Use our community feedback tool to let others know what worked for you and what
didn't.
Please also understand that the community feedback system is not warranted to be
correct, it's simply a system that we've built to let people try and help each
other. If something in a feedback response doesn't make sense to you, or you're
not comfortable making changes that the feedback talks about (like registry
edits), please consult a professional.
Thank you for using kbAlertz.com Feedback System.
-- Scott Cate