📄 vbs224.htm
字号:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"><HTML><HEAD><TITLE>Comparison Operators</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="operators,comparing values,comparison operators,relational operators,operators comparison,operators relational,symbols comparison operator,symbols"><META NAME="Description" CONTENT="Comparison Operators"></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>Comparison Operators</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="vbs225.htm">See Also</A></FONT>
<HR NOSHADE SIZE=1>
<H5>Description</H5>
<BLOCKQUOTE>Used to compare expressions.</BLOCKQUOTE>
<H5>Syntax</H5>
<BLOCKQUOTE><i>result</i> <b>=</b> <i>expression1</i> <i>comparisonoperator</i> <i>expression2<P>result </i><b>=</b> <i>object1</i><b> Is </b><i>object2</i><P>
Comparison operators have 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>result</i></FONT></TD>
<TD><FONT SIZE=2>Any numeric variable.</FONT></TD></TR>
<TR VALIGN=TOP>
<TD><FONT SIZE=2><i>expression</i></FONT></TD>
<TD><FONT SIZE=2>Any <A HREF="vbs0.htm#defExpression">expression</A>.</FONT></TD></TR>
<TR VALIGN=TOP>
<TD><FONT SIZE=2><i>comparisonoperator</i></FONT></TD>
<TD><FONT SIZE=2>Any <A HREF="vbs0.htm#defComparisonOperator">comparison operator</A>.</FONT></TD></TR>
<TR VALIGN=TOP>
<TD><FONT SIZE=2><i>object</i></FONT></TD>
<TD><FONT SIZE=2>Any object name.</FONT></TD></TR>
<!--TR VALIGN=TOP>
<TD><FONT SIZE=2><i>string</i></FONT></TD>
<TD><FONT SIZE=2>Any <A HREF="vbs0.htm#defStringExpression">string expression</A>.</FONT></TD></TR>
<TR VALIGN=TOP>
<TD><FONT SIZE=2><i>pattern</i></FONT></TD>
<TD><FONT SIZE=2>Any string expression or range of characters.</FONT></TD></TR-->
</TABLE></BLOCKQUOTE><P>
<H5>Remarks</H5>
<BLOCKQUOTE>The <b>Is</b> operator has specific comparison functionality that differs from the operators in the following table. The following table contains a list of the comparison operators and the conditions that determine whether <i>result</i> is <b>True</b>, <b>False</b>, or <A HREF="vbs0.htm#defNull"><b>Null</b></A>:<P>
<TABLE WIDTH=87% BORDER=1 CELLPADDING=5 CELLSPACING=0>
<TR VALIGN=TOP BGCOLOR="#DDDDDD">
<TD><FONT SIZE=2><b>Operator</b></FONT></TD>
<TD><FONT SIZE=2><b>Description</b></FONT></TD>
<TD><FONT SIZE=2><b>True if</b></FONT></TD>
<TD><FONT SIZE=2><b>False if</b></FONT></TD>
<TD><FONT SIZE=2><b>Null if</b></FONT></TD></TR>
<TR VALIGN=TOP>
<TD ALIGN=CENTER><FONT SIZE=2><b><</b></FONT></TD>
<TD><FONT SIZE=2>Less than</FONT></TD>
<TD><FONT SIZE=2><i>expression1</i> < <i>expression2</i></FONT></TD>
<TD><FONT SIZE=2><i>expression1</i> >= <i>expression2</i></FONT></TD>
<TD><FONT SIZE=2><i>expression1</i> or <i>expression2</i> = <b>Null</b></FONT></TD></TR>
<TR VALIGN=TOP>
<TD ALIGN=CENTER><FONT SIZE=2><b><=</b></FONT></TD>
<TD><FONT SIZE=2>Less than or equal to</FONT></TD>
<TD><FONT SIZE=2><i>expression1</i> <= <i>expression2</i></FONT></TD>
<TD><FONT SIZE=2><i>expression1</i> > <i>expression2</i></FONT></TD>
<TD><FONT SIZE=2><i>expression1</i> or <i>expression2</i> = <b>Null</b></FONT></TD></TR>
<TR VALIGN=TOP>
<TD ALIGN=CENTER><FONT SIZE=2><b>></b></FONT></TD>
<TD><FONT SIZE=2>Greater than</FONT></TD>
<TD><FONT SIZE=2><i>expression1</i> > <i>expression2</i></FONT></TD>
<TD><FONT SIZE=2><i>expression1</i> <= <i>expression2</i></FONT></TD>
<TD><FONT SIZE=2><i>expression1</i> or <i>expression2</i> = <b>Null</b></FONT></TD></TR>
<TR VALIGN=TOP>
<TD ALIGN=CENTER><FONT SIZE=2><b>>=</b></FONT></TD>
<TD><FONT SIZE=2>Greater than or equal to</FONT></TD>
<TD><FONT SIZE=2><i>expression1</i> >= <i>expression2</i></FONT></TD>
<TD><FONT SIZE=2><i>expression1</i> < <i>expression2</i></FONT></TD>
<TD><FONT SIZE=2><i>expression1</i> or <i>expression2</i> = <b>Null</b></FONT></TD></TR>
<TR VALIGN=TOP>
<TD ALIGN=CENTER><FONT SIZE=2><b>=</b></FONT></TD>
<TD><FONT SIZE=2>Equal to</FONT></TD>
<TD><FONT SIZE=2><i>expression1</i> = <i>expression2</i></FONT></TD>
<TD><FONT SIZE=2><i>expression1</i> <> <i>expression2</i></FONT></TD>
<TD><FONT SIZE=2><i>expression1</i> or <i>expression2</i> = <b>Null</b></FONT></TD></TR>
<TR VALIGN=TOP>
<TD ALIGN=CENTER><FONT SIZE=2><b><></b></FONT></TD>
<TD><FONT SIZE=2>Not equal to</FONT></TD>
<TD><FONT SIZE=2><i>expression1</i> <> <i>expression2</i></FONT></TD>
<TD><FONT SIZE=2><i>expression1</i> = <i>expression2</i></FONT></TD>
<TD><FONT SIZE=2><i>expression1</i> or <i>expression2</i> = <b>Null</b></FONT></TD></TR></TABLE><P>
When comparing two expressions, you may not be able to easily determine whether the expressions are being compared as numbers or as strings.<P>
The following table shows how expressions are compared or what results from the comparison, depending on the underlying subtype:<P>
<TABLE WIDTH=87% BORDER=1 CELLPADDING=5 CELLSPACING=0>
<TR VALIGN=TOP BGCOLOR="#DDDDDD">
<TD><FONT SIZE=2><b>If </b></FONT></TD>
<TD><FONT SIZE=2><b>Then</b></FONT></TD></TR>
<TR VALIGN=TOP>
<TD><FONT SIZE=2>Both expressions are numeric</FONT></TD>
<TD><FONT SIZE=2>Perform a numeric comparison.</FONT></TD></TR>
<TR VALIGN=TOP>
<TD><FONT SIZE=2>Both expressions are strings</FONT></TD>
<TD><FONT SIZE=2>Perform a <A HREF="vbs0.htm#defStringComparison">string comparison</A>.</FONT></TD></TR>
<TR VALIGN=TOP>
<TD><FONT SIZE=2>One expression is numeric and the other is a string</FONT></TD>
<TD><FONT SIZE=2>The numeric expression is less than the string expression.</FONT></TD></TR>
<TR VALIGN=TOP>
<TD><FONT SIZE=2>One expression is <A HREF="vbs0.htm#defEmpty"><b>Empty</b></A> and the other is numeric</FONT></TD>
<TD><FONT SIZE=2>Perform a numeric comparison, using 0 as the <b>Empty</b> expression.</FONT></TD></TR>
<TR VALIGN=TOP>
<TD><FONT SIZE=2>One expression is <b>Empty</b> and the other is a string</FONT></TD>
<TD><FONT SIZE=2>Perform a string comparison, using a zero-length string ("") as the <b>Empty</b> expression.</FONT></TD></TR>
<TR VALIGN=TOP>
<TD><FONT SIZE=2>Both expressions are <b>Empty</b></FONT></TD>
<TD><FONT SIZE=2>The expressions are equal.</FONT></TD></TR></TABLE>
</BLOCKQUOTE><p>
<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 + -