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

📄 vbs5.htm

📁 VBScript 是一种脚本语言
💻 HTM
字号:
<HTML>
<HEAD>
<TITLE>VBScript Constants</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="Tutorial">
<META NAME="Description" CONTENT="VBScript Constants">
</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>VBScript Constants</B></FONT>

</TD>
<TD ALIGN=RIGHT>
<FONT SIZE=2>&nbsp;<A HREF="vbstutor.htm">VBScript&nbsp;Tutorial</A>&nbsp;<BR>&nbsp;<A HREF="vbs15.htm">Previous</A>&nbsp;|&nbsp;<A HREF="vbs13.htm">Next</A>&nbsp;<P></FONT>


</TD></TR>
</TABLE> 
&nbsp;<BR>

<HR NOSHADE SIZE=1>

<H5>What Is a Constant?</H5>
<BLOCKQUOTE>
A <A HREF="vbs0.htm#defConstant">constant</A> is a meaningful name that takes the place of a number or string and never changes. VBScript defines a number of <A HREF="vbs0.htm#defIntrinsicConstant">intrinsic constants</A>. You can get information about these intrinsic constants from the <a href="vbsTOC.htm">VBScript Language Reference</a>.
</BLOCKQUOTE>

<H5>Creating Constants</H5>
<BLOCKQUOTE>
You create user-defined constants in VBScript using the <a href="vbs569.htm"><b>Const</b></a> statement. Using the <B>Const</B> statement, you can create string or numeric constants with meaningful names and assign them literal values. For example:

<BLOCKQUOTE><PRE><FONT FACE="Courier New" SIZE=3>Const MyString = "This is my string."
Const MyAge = 49
</FONT></PRE>
</BLOCKQUOTE>

Note that the string literal is enclosed in quotation marks (" "). Quotation marks are the most obvious way to differentiate string values from numeric values. <A HREF="vbs0.htm#defDateLiteral">Date literals</A> and time literals are represented by enclosing them in number signs (#). For example:

<BLOCKQUOTE><PRE><FONT FACE="Courier New" SIZE=3>Const CutoffDate = #6-1-97#
</FONT></PRE>
</BLOCKQUOTE>

You may want to adopt a naming scheme to differentiate constants from variables. This will prevent you from trying to reassign constant values while your script is running.  For example, you might want to use a "vb" or "con" prefix on your constant names, or you might name your constants in all capital letters. Differentiating constants from variables eliminates confusion as you develop more complex scripts.
</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 + -