校园春色亚洲色图_亚洲视频分类_中文字幕精品一区二区精品_麻豆一区区三区四区产品精品蜜桃

主頁 > 知識庫 > ASP中一個用VBScript寫的隨機數類

ASP中一個用VBScript寫的隨機數類

熱門標簽:金昌電話機器人價格 縣域地圖標注打印店 外呼系統API接口 修改地圖標注 怎么在地圖標注自己 個人可以辦理400電話么 武夷山旅游地圖標注 萊西電子地圖標注 鳳臺百度地圖標注店
外國人寫的一個class,這么一點小小的應用,除非有特殊需求,還沒有必要模塊化。
用asp產生一個隨機數。

''************************************************************************** 
'' 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)
您可能感興趣的文章:
  • ASP、vbscript編碼模板
  • 利用vbscript腳本修改文件內容,此適用于自動化的操作中
  • asp,VBscript語法錯誤,史上最全最詳細最精確
  • vbscript腳本編程教程2利用fso來進行文件操作
  • 使用vbscript腳本在表單中進行選擇的代碼
  • 用vbscript腳本實現返回 IP 配置數據的代碼
  • ASP里面令人震撼地Debug類(VBScript)
  • 調試JavaScript/VBScript腳本程序(IE篇)
  • JavaScript/VBScript腳本程序調試(Wscript篇)
  • 枚舉域內計算機個數vbscript腳本(沒環境,沒測試)
  • ASP/VBScript中CHR(0)的由來以及帶來的安全問題分析
  • ASP(VBScript)中整除和取余
  • ASP基礎知識VBScript基本元素講解
  • ASP基礎入門第四篇(腳本變量、函數、過程和條件語句)

標簽:通遼 邢臺 南京 清遠 赤峰 涼山 上海 楚雄

巨人網絡通訊聲明:本文標題《ASP中一個用VBScript寫的隨機數類》,本文關鍵詞  ASP,中,一個,用,VBScript,寫的,;如發現本文內容存在版權問題,煩請提供相關信息告之我們,我們將及時溝通與處理。本站內容系統采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《ASP中一個用VBScript寫的隨機數類》相關的同類信息!
  • 本頁收集關于ASP中一個用VBScript寫的隨機數類的相關信息資訊供網民參考!
  • 推薦文章
    主站蜘蛛池模板: 桐乡市| 墨竹工卡县| 镇原县| 岳阳县| 南阳市| 库尔勒市| 舒城县| 宁河县| 宜君县| 昭苏县| 永丰县| 从江县| 鄂伦春自治旗| 漳平市| 勃利县| 韩城市| 中阳县| 雅安市| 桂阳县| 江永县| 襄垣县| 桐城市| 太康县| 天祝| 尚志市| 兴化市| 离岛区| 曲沃县| 洮南市| 友谊县| 清丰县| 无极县| 咸丰县| 长阳| 澄城县| 育儿| 海兴县| 永吉县| 泽州县| 南靖县| 柞水县|