English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
所有分類

我不會這個程式碼..
請各位程式高手為我解答...
在程式後面作註解唷..^^

Dim Ans, 水果
Dim X As Integer

Private Sub Command1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
No = Int(Rnd() * UBound(水果))
Label3.Caption = 水果(No)
Label5.Caption = ""
Ans = 水果(No)
Timer1.Enabled = True
End Sub

Private Sub Command2_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Label5.Caption = Ans Then
X = MsgBox("您記憶力一級棒!")
Else

X = MsgBox("您的記憶力有待加強!")
End If
End Sub

Private Sub Form_Load()
水果 = Array("apple", "pear", "apricot", "peach", "grape", "banana", "pineapple", "plum", _

"watermelon", "orange", "lemon", "mango", "strawberry", "medlar", "mulberry", "nectarine", _

"cherry", "pomegranate", "fig", "tangerine", "persimmon", "walnut", "hazelnut", "peanut", _

"date", "chestnut", "currant", "coconut", "bilberry", "black berry", "avocado", "black currant", _
"blood orange", "citron grapefruit", "damson", "almond", "nutmeg", "papaya", "guava", "prickly pear", _
"raspberry", "soursop")
Randomize
End Sub

Private Sub Command1_KeyPress(KeyAscii As Integer)
Label5.Caption = Label5.Caption & Chr(KeyAscii)
End Sub

Private Sub Timer1_Timer()
Label3.Caption = ""
Timer1.Enabled = False
End Sub

2005-07-02 19:29:51 · 2 個解答 · 發問者 小白 5 in 電腦與網際網路 程式設計

2 個解答

'我不會這個程式碼..
'請各位程式高手為我解答...
'在程式後面作註解唷..^^

Dim Ans, 水果 '宣告兩個自由形態的變數

Dim X As Integer '宣告一個整數變數

Private Sub Command1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) '當滑鼠在command1按下時發生的事件

No = Int(Rnd() * UBound(水果)) '隨機取一個大於0但小於水果陣列個數的整數,假設是3

Label3.Caption = 水果(No) '把隨機取到的整數3當做是水果陣列的引數,並把該位置的值peach給Label3

Label5.Caption = "" '把label5清空
Ans = 水果(No) '把剛剛的值peach存在ans內
Timer1.Enabled = True '剛始計時
End Sub

Private Sub Command2_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) '當滑鼠在command2按下時發生的事件

If Label5.Caption = Ans Then '判斷Label5的值是不是等於ans(peach)

X = MsgBox("您記憶力一級棒!") '如果是,則出現這一個對話框
Else

X = MsgBox("您的記憶力有待加強!") '如果不是,則出現這一個對話框
End If
End Sub

Private Sub Form_Load() '當表單載入時發生的事件

水果 = Array("apple", "pear", "apricot", "peach", "grape", "banana", "pineapple", "plum", _
"watermelon", "orange", "lemon", "mango", "strawberry", "medlar", "mulberry", "nectarine", _
"cherry", "pomegranate", "fig", "tangerine", "persimmon", "walnut", "hazelnut", "peanut", _
"date", "chestnut", "currant", "coconut", "bilberry", "black berry", "avocado", "black currant", _
"blood orange", "citron grapefruit", "damson", "almond", "nutmeg", "papaya", "guava", "prickly pear", _
"raspberry", "soursop") '給水果初使值 *切記,行與行間不可空白喔…如果要空白,也要加上_
Randomize '取亂數種子 *建議加上(timer())會比較好
End Sub

Private Sub Command1_KeyPress(KeyAscii As Integer) '當command1取得焦點,而且你在上面打字時發生的事件

Label5.Caption = Label5.Caption & Chr(KeyAscii) '把你打的字顯示在Label5上
End Sub

Private Sub Timer1_Timer() '當timer1.interval的值到了時,就會執行的事件
Label3.Caption = "" '令label3的值為空白
Timer1.Enabled = False '令時間暫停
End Sub

2005-07-03 05:18:17 · answer #1 · answered by 上官 5 · 0 0

http://tw.knowledge.yahoo.com/question/?qid=1105070105092
幫我看看這題好嗎?

2005-07-03 02:20:21 · answer #2 · answered by Julie 7 · 0 0

fedest.com, questions and answers