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

📄 vbs175.htm

📁 VBScript 是一种脚本语言
💻 HTM
字号:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"><HTML>
<HEAD><TITLE>Rnd Function</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="Rnd function,Random,math functions,random numbers,numbers random,pseudorandom numbers,numbers pseudorandom,generating random numbers,numbers"><META NAME="Description" CONTENT="Rnd Function"></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>Rnd Function</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;1</A>&nbsp;<P></FONT>
</TD></TR>
</TABLE> 
<FONT SIZE=2><P>
<A HREF="vbs176.htm">See Also</A></FONT>
<HR NOSHADE SIZE=1>

<H5>Description</H5>
<BLOCKQUOTE>Returns a random number.</BLOCKQUOTE>

<H5>Syntax</H5>
<BLOCKQUOTE><b>Rnd</b>[<b>(</b><i>number</i><b>)</b>]<P>
The <i>number</i> argument can be any valid 
<A HREF="vbs0.htm#defNumericExpression">numeric expression</A>.</BLOCKQUOTE>

<H5>Remarks</H5>
<BLOCKQUOTE>The <b>Rnd</b> function returns a value less than 1 but greater than or equal to 0.<P>
The value of <i>number</i> determines how <b>Rnd</b> generates a random number:<P>

<TABLE WIDTH=87% BORDER=1 CELLPADDING=5 CELLSPACING=0>
<TR VALIGN=TOP BGCOLOR="#DDDDDD">
<TD><FONT SIZE=2><b>If <i>number</i> is</b></FONT></TD>
<TD><FONT SIZE=2><b>Rnd generates</b></FONT></TD></TR>
<TR VALIGN=TOP>
<TD><FONT SIZE=2>Less than zero</FONT></TD>
<TD><FONT SIZE=2>The same number every time, using <i>number</i> as the 
<A HREF="vbs0.htm#defSeed">seed</A>.</FONT></TD></TR>
<TR VALIGN=TOP>
<TD><FONT SIZE=2>Greater than zero</FONT></TD>
<TD><FONT SIZE=2>The next random number in the sequence.</FONT></TD></TR>
<TR VALIGN=TOP>
<TD><FONT SIZE=2>Equal to zero</FONT></TD>
<TD><FONT SIZE=2>The most recently generated number.</FONT></TD></TR>
<TR VALIGN=TOP>
<TD><FONT SIZE=2>Not supplied</FONT></TD>
<TD><FONT SIZE=2>The next random number in the sequence.</FONT></TD></TR></TABLE><P>

For any given initial seed, the same number sequence is generated because each successive call to the <b>Rnd</b> function uses the previous number as a seed for the next number in the sequence.<P>
Before calling <b>Rnd</b>, use the <b>Randomize</b> statement without an argument to initialize the random-number generator with a seed based on the system timer.<P>

To produce random integers in a given range, use this formula:<P>
<BLOCKQUOTE><PRE><FONT FACE="Courier New" SIZE=3>Int((<i>upperbound</i> - <i>lowerbound</i> + 1) * <FONT COLOR=#FF0000>Rnd</FONT> + <i>lowerbound</i>)
</FONT></PRE>
</BLOCKQUOTE>

Here, <i>upperbound</i> is the highest number in the range, and <i>lowerbound</i> is the lowest number in the range.

<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;To repeat sequences of random numbers, call <b>Rnd</b> with a negative argument immediately before using <b>Randomize</b> with a numeric argument. Using <b>Randomize</b> with the same value for <i>number</i> does not repeat the previous sequence.</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 + -