最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

ASP中一個用VBScript寫的隨機數(shù)類

 更新時間:2006年08月27日 00:00:00   作者:  
外國人寫的一個class,這么一點小小的應(yīng)用,除非有特殊需求,還沒有必要模塊化。
用asp產(chǎn)生一個隨機數(shù)。
<% 
''************************************************************************** 
'' CLASS: cRandom 
'' Calls randomize to seed the random number generator. 
'' Provides functions for returning ranged random integers or arrays of 
'' ranged random integers. 
'' Calling randomize to seed the random number generator at the time the 
'' class is created seemed like a reasonable thing to do. 
private sub Class_Initialize() 
'' Check the VBScript documentation for the specifics relating 
'' to the Randomize function 
Randomize 
end sub 
'' Terminate doesn''t need to do anything for this class 
private sub Class_Terminate() 
end sub 
''********************************************************************** 
'' FUNCTION: RangedRandom 
'' PARAMETER: lowerBound, the lowest allowable number to return 
'' PARAMETER: upperBound, the highest allowable number to return 
'' RETURNS: A random integer between lowerBound and UpperBound, 
'' inclusive 
''********************************************************************** 
public function RangedRandom( lowerBound, upperBound ) 
RangedRandom = CInt((upperBound - lowerBound) * Rnd + lowerBound) 
end function 
''********************************************************************** 
'' FUNCTION: RangedRandomArray 
'' PARAMETER: lowerBound, the lowest allowable number to return 
'' PARAMETER: upperBound, the highest allowable number to return 
'' PARAMETER: arraySize, zero based number specifying the size of the array 
'' PARAMETER: duplicates, true or false to indicate whether duplicate 
'' resize the tempArray to hold the number of elements passed in the 
'' arraySize parameter 
redim tempArray(arraySize) 
'' This is a loop counter, set it to 0 
filledElements = 0 
'' loop until filledElements is equal to the arraySize + 1 
do until filledElements = arraySize + 1 
'' Call the RangedRandom function with the lowerBound and upperBoundparameters 
tempValue = RangedRandom( lowerBound, upperBound ) 
'' Handle the case where we don''t want duplicate values 
if duplicates = false then 
badValue = false 
for i = 0 to UBound(tempArray) 
'' check if the new random value already exists in the array 
'' if it does set the badValue flag to true and break out of the loop 
if tempValue = tempArray(i) then 
badValue = true 
exit for 
end if 
next 
if badValue = false then 
tempArray(filledElements) = tempValue 
filledElements = filledElements + 1 
end if 
else 
'' Handle the case where duplicate values in the array are acceptable 
tempArray(filledElements) = tempValue 
filledElements = filledElements + 1 
end if 
loop 
'' return the array 
RangedRandomArray = tempArray 
end function 
end class 
%> 
<% 
'' All the code that follows is example code showing the use of the 
'' cRandom class. 
dim objRandom 
dim flip 
dim randomArray 
dim rowsToTest 
dim i, j 
'' create an instance of our class 
set objRandom = new cRandom 
'' set the number of iterations that we want to test 
rowsToTest = 10 
'' "toggle" to determine whether or not we set the bgcolor of the table row 
flip = true 
'' Start the table 
Response.Write "<table border=0 cellpadding=1 cellspacing=1>" 
for j = 0 to rowsToTest 
'' We''ll alternate the bgcolor of the table rows based on the 
'' value of the flip variable 
if flip then 
Response.Write "<tr bgcolor=LightGrey>" 
else 
Response.Write "<tr>" 
end if 
'' Call the RangedRandomArray function for testing purposes 
randomArray = objRandom.RangedRandomArray( 1, 10)
  • EasyASP v1.5發(fā)布(包含數(shù)據(jù)庫操作類,原clsDbCtrl.asp)

    EasyASP v1.5發(fā)布(包含數(shù)據(jù)庫操作類,原clsDbCtrl.asp)

    EasyASP是一個方便快速開發(fā)ASP的類,其中包含了一個數(shù)據(jù)庫控制類(原clsDbCtrl.asp,對原代碼作了優(yōu)化和修改,包含對數(shù)據(jù)庫的各類操作及存儲過程的調(diào)用,全部封裝在Easp.db中,使用起來會更方便,調(diào)用也更簡單)。
    2008-10-10
  • ASP類Class入門 推薦

    ASP類Class入門 推薦

    我們常??吹絼e的程序語言中中都有類的說明,PHP,VB,C++,這個在VBScript中的類的說明,我是第一次聽到,我們的日常工作就是網(wǎng)站開發(fā),在這個里面多多少少搞出點經(jīng)驗,像模像樣也能自詡為內(nèi)行,所以我就來分享一下我所知道的這個新的東東
    2006-08-08
  • ASP 使用三層架構(gòu) asp中使用類

    ASP 使用三層架構(gòu) asp中使用類

    Class在asp中出現(xiàn)蠻久了,不過很少看到它被用在代碼當中.記得當年研究動網(wǎng)的論壇程序的時候,看到了一些例子,當時還覺得比較崇拜----對自己沒用過的技術(shù).
    2009-09-09
  • asp:debug類調(diào)試程序

    asp:debug類調(diào)試程序

    asp:debug類調(diào)試程序...
    2007-02-02
  • Access 2000 數(shù)據(jù)庫 80 萬記錄通用快速分頁類

    Access 2000 數(shù)據(jù)庫 80 萬記錄通用快速分頁類

    Access 2000 數(shù)據(jù)庫 80 萬記錄通用快速分頁類...
    2007-03-03
  • ASP中一個用VBScript寫的隨機數(shù)類

    ASP中一個用VBScript寫的隨機數(shù)類

    ASP中一個用VBScript寫的隨機數(shù)類...
    2006-08-08
  • 最新評論

    陈巴尔虎旗| 株洲市| 淅川县| 青岛市| 乌拉特前旗| 神池县| 大冶市| 嘉峪关市| 漳浦县| 古丈县| 澄城县| 宁武县| 特克斯县| 钦州市| 崇州市| 新龙县| 开远市| 剑河县| 晋宁县| 墨脱县| 浮梁县| 松滋市| 新和县| 灌阳县| 罗源县| 怀来县| 格尔木市| 海南省| 平邑县| 棋牌| 宜宾市| 长汀县| 长治县| 安仁县| 东光县| 永顺县| 汉源县| 丰都县| 陈巴尔虎旗| 砀山县| 萨嘎县|