⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vbs569.htm

📁 VBScript 是一种脚本语言
💻 HTM
字号:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"><HTML><HEAD><TITLE>Const Statement</TITLE> 
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso8859-1">
<META NAME="MS.LOCALE" CONTENT="EN-US">
<META NAME="PRODUCT" CONTENT="Visual Basic Scripting Edition">
<META NAME="TECHNOLOGY" CONTENT="SCRIPTING">
<META NAME="CATEGORY" CONTENT="Language Reference">

<META NAME="Keywords" CONTENT=""><META NAME="Description" CONTENT="Const Statement"></HEAD>

<BODY BGCOLOR=FFFFFF LINK=#0033CC>
<!--TOOLBAR_START-->
<!--TOOLBAR_EXEMPT-->
<!--TOOLBAR_END-->
<FONT FACE="Verdana, Arial, Helvetica" SIZE=2>
<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%><TR VALIGN=TOP><TD WIDTH=360>
<FONT SIZE=1 COLOR=#660033>Microsoft&#174; Visual Basic&#174; Scripting Edition</FONT><BR>
<FONT SIZE=5 COLOR=#660033><B>Const Statement</B></FONT>

</TD>
<TD ALIGN=RIGHT>
<FONT SIZE=2>&nbsp;<A HREF="vbstoc.htm">Language&nbsp;Reference</A>&nbsp;<BR>
<A HREF="vbs16.htm">Version&nbsp;2</A>&nbsp;<P></FONT>
</TD></TR>
</TABLE> 

<FONT SIZE=2><p>
<A HREF="vbs570.htm">See Also</A></FONT>
<HR noshade SIZE=1>

<H5>Description</H5>
<BLOCKQUOTE>
Declares <A HREF="vbs0.htm#defConstant">constants</A> for use in place of literal values.
</BLOCKQUOTE>

<H5>Syntax</H5>
<BLOCKQUOTE>
[<b>Public</b> | <b>Private</b>]<b> Const</b> <i>constname</i> = <i>expression</i><P>

The <b>Const</b> statement syntax has these parts:<P>

<TABLE WIDTH=87% BORDER=1 CELLPADDING=5 CELLSPACING=0>
<TR VALIGN=TOP BGCOLOR="#DDDDDD">
<TD><FONT SIZE=2><b>Part</b></FONT></TD>
<TD><FONT SIZE=2><b>Description</b></FONT></TD></TR>
<TR VALIGN=TOP>
<TD><FONT SIZE=2><B>Public</B></FONT></TD>
<TD><FONT SIZE=2>Optional. Keyword used at <A HREF="vbs0.htm#defScriptLevel">script level</A> to declare constants that are available to all procedures in all scripts. Not allowed in procedures.</FONT></TD></TR>
<TR VALIGN=TOP>
<TD><FONT SIZE=2><B>Private</B></FONT></TD>
<TD><FONT SIZE=2>Optional. Keyword used at script level to declare constants that are available only within the script where the declaration is made. Not allowed in procedures.</FONT></TD></TR>

<TR VALIGN=TOP>
<TD><FONT SIZE=2><i>constname</i></FONT></TD>
<TD><FONT SIZE=2>Required. Name of the constant; follows standard <A HREF="vbs0.htm#defVariable">variable</A> naming conventions.</FONT></TD></TR>

<TR VALIGN=TOP>
<TD><FONT SIZE=2><i>expression</i></FONT></TD>
<TD><FONT SIZE=2>Required. Literal or other constant, or any combination that includes all arithmetic or logical operators except <B>Is</B>.</FONT></TD></TR>

</TABLE>
</BLOCKQUOTE>

<H5>Remarks</H5>
<BLOCKQUOTE>
Constants are public by default. Within procedures, constants are always private; their visibility can't be changed. Within a script, the default visibility of a script-level constant can be changed using the <B>Private</B> keyword.<P>

To combine several constant declarations on the same line, separate each constant assignment with a comma. When constant declarations are combined in this way, the <B>Public</B> or<B> Private</B> keyword, if used, applies to all of them.<P>

You can't use variables, user-defined functions, or intrinsic VBScript functions (such as <b>Chr</b>) in constant declarations. By definition, they can't be constants. You also can't create a constant from any expression that involves an operator, that is, only simple constants are allowed.

Constants declared in a <B>Sub</B> or <B>Function</B> procedure are local to that procedure. A constant declared outside a procedure is defined throughout the script in which it is declared. You can use constants anywhere you can use an expression.

<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0 WIDTH=87%><TR><TD COLSPAN=2 VALIGN=BOTTOM><HR noshade size=1></TD></TR><TR><TD VALIGN=TOP><FONT SIZE=2><b>Note</b>&nbsp;&nbsp;Constants can make your scripts self-documenting and easy to modify. Unlike variables, constants can't be inadvertently changed while your script is running.</FONT></TD></TR><TR><TD COLSPAN=2 VALIGN=TOP><HR noshade size=1></TD></TR></TABLE></BLOCKQUOTE>

<hr noshade size=1>
<p align=center><em><a href="../../common/colegal.htm">&copy; 1997 by Microsoft Corporation. All rights reserved.</a></em></p> 
</FONT></BODY></HTML>


















































































⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -