VB-random的問題

2008-06-08 11:07 pm
我有一條vb既題目唔知應點寫個code呀~~
可唔可以教下我呀~唔應.
個問題係:

Write a function Random_1_6 ( ) to return a random number between 1 and 6

回答 (3)

2008-06-10 12:18 pm
✔ 最佳答案
Function Random_1_6 ( )
Dim Rnd As New Random()
Return Rnd.Next(1, 6)
End Function

2008-06-10 04:33:08 補充:
這裏用了.NET Framework Random class 的方法。

2008-06-10 04:33:23 補充:
樓上 y6972593 (002) 的方法是正確的,想知點解要
Random_1_6 = Int((Hi - Lo + 1) * Rnd() + Lo)
請看 http://hk.knowledge.yahoo.com/question/question?qid=7007052103587
coding 是 javascript,看 comment 就明。

2008-06-10 04:45:21 補充:
少少更正
Function Random_1_6 ( )
Dim Rnd As New Random()
Return Rnd.Next(1, 7) ' <-- 7 not 6
End Function
2008-06-09 5:07 am
First you would create a button (Button1) which will generate a random number each time you press it. Then you create a textbox (TextBox1) that displays the generated random number.

Double-click on the button to go to the code page and enter the Function definition and the contents of the Button1_Click processor.
An example of the code can be copied and pasted. Make sure you understand everything explained in the code.
Example output and code can be found at the following link, look under question id=7008060801335.
http://mathmate.brinkster.net/programming.htm
2008-06-09 4:10 am
你好,我推薦你一個關于 Xanga 基本語法教學的網站,他包括許多 Xanga 的小技巧, Xanga Skin, Xanga Script.

http://www.xanga-help.com

希望這個網站對你有參考價值。

祝你好運!


收錄日期: 2021-04-13 15:40:22
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20080608000051KK01335

檢視 Wayback Machine 備份