📄 vbs598.htm
字号:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"><HTML>
<HEAD>
<TITLE>Select Case 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="Description" CONTENT="Select Case 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® Visual Basic® Scripting Edition</FONT><BR>
<FONT SIZE=5 COLOR=#660033><B>Select Case Statement</B></FONT>
</TD>
<TD ALIGN=RIGHT>
<FONT SIZE=2> <A HREF="vbstoc.htm">Language Reference</A> <BR>
<A HREF="vbs16.htm">Version 1</A> <P></FONT>
</TD></TR>
</TABLE>
<FONT SIZE=2><p>
<A HREF="vbs599.htm">See Also</A></FONT>
<HR noshade SIZE=1>
<H5>Description</H5>
<BLOCKQUOTE>
Executes one of several groups of statements, depending on the value of an expression.
</BLOCKQUOTE>
<H5>Syntax</H5>
<BLOCKQUOTE><b>Select Case</b> <i>testexpression</i><BR>
[<b>Case</b><i> expressionlist-n</i><BR>
[<i>statements-n</i>]] <b>. . .</b><BR>
[<b>Case Else</b><i> expressionlist-n</i><BR>
[<i>elsestatements-n</i>]]<BR>
<b>End Select</b><P>
The <b>Select Case</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><i>testexpression</i></FONT></TD>
<TD><FONT SIZE=2>Any <A HREF="vbs0.htm#defNumericExpression">numeric</A> or <A HREF="vbs0.htm#defStringExpression">string expression</A>.</FONT></TD></TR>
<TR VALIGN=TOP>
<TD><FONT SIZE=2><i>expressionlist-n</i></FONT></TD>
<TD><FONT SIZE=2>Required if <b>Case</b> appears. Delimited list of one or more expressions.</FONT></TD></TR>
<TR VALIGN=TOP>
<TD><FONT SIZE=2><i>statements-n</i></FONT></TD>
<TD><FONT SIZE=2>One or more statements executed if <i>testexpression</i> matches any part of <i>expressionlist-n</i>.</FONT></TD></TR>
<TR VALIGN=TOP>
<TD><FONT SIZE=2><i>elsestatements</i></FONT></TD>
<TD><FONT SIZE=2>One or more statements executed if <I>testexpression </I>doesn't match any of the <B>Case</B> clauses.</FONT></TD></TR>
</TABLE>
</BLOCKQUOTE>
<H5>Remarks</H5>
<BLOCKQUOTE>
If <I>testexpression</I> matches any <B>Case</B> <I>expressionlist</I> expression, the statements following that <B>Case</B> clause are executed up to the next <B>Case</B> clause, or for the last clause, up to <B>End Select</B>. Control then passes to the statement following <B>End Select</B>. If <I>testexpression</I> matches an <I>expressionlist</I> expression in more than one <B>Case</B> clause, only the statements following the first match are executed.<P>
The <B>Case Else</B> clause is used to indicate the <I>elsestatements</I> to be executed if no match is found between the <I>testexpression</I> and an <I>expressionlist</I> in any of the other <B>Case</B> selections. Although not required, it is a good idea to have a <B>Case Else</B> statement in your <B>Select Case</B> block to handle unforeseen <i>testexpression</i> values. If no <B>Case</B> <I>expressionlist</I> matches <I>testexpression</I> and there is no <B>Case Else</B> statement, execution continues at the statement following <B>End Select</B>.<P>
<B>Select Case</B> statements can be nested. Each nested <B>Select Case</B> statement must have a matching <B>End Select</B> statement.
</BLOCKQUOTE>
<hr noshade size=1>
<p align=center><em><a href="../../common/colegal.htm">© 1997 by Microsoft Corporation. All rights reserved.</a></em></p>
</FONT>
</BODY>
</HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -