作者ybigghost (鯊魚)
看板Visual_Basic
標題[VB6 ] 新手問題
時間Wed Aug 14 03:41:43 2013
Private Sub Command1_Click()
Select Case a '判斷a變數
Case 1 '如果是1就顯示金
Text2.Text = "金"
Case 2 '如果是2就顯示木
Text2.Text = "木"
Case 3 '如果是3就顯示水
Text2.Text = "水"
Case 4 '如果是4就顯示火
Text2.Text = "火"
Case 5 '如果是5就顯示土
Text2.Text = "土"
End Select '結束這ㄍ判斷
Command1.Enabled = False
If a = 2 Then
Text1.Text = "電腦-20%血量!"
Else
If a = 4 Then
Text1.Text = "玩家-20%血量!"
Else
If a = 1 Then
Text1.Text = "平手"
Else
If a = 3 Then
Text1.Text = "平手"
Else
If a = 5 Then
Text1.Text = "平手"
End If
End If
End If
End If
End If
End Sub
Private Sub Command6_Click()
Randomize
Dim t(5) As Integer
For i = 1 To 5
ReNumber:
t(i) = Int(Rnd * 5) + 1
For j = 1 To 5
If i <> j And t(i) = t(j) Then GoTo ReNumber:
Next
Next
a = t(1)
b = t(2)
c = t(3)
d = t(4)
e = t(5)
End Sub
我先按 按鈕六 在按 按鈕一 為什麼抓不到 a的值
要怎樣才能抓到呢@@?
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 122.116.128.174
1F:推 Marty:在最前面加一個 Public value 再從這個value給值 取值 08/14 07:57
2F:→ ybigghost:是按鈕一的最前面嗎? 08/14 16:48
3F:→ ybigghost:要怎麼給值啊? 我google 找不到 .. 08/14 16:48
4F:→ EShensh:看到 Goto 熊熊有點不適應... =_= 08/14 16:50
5F:→ Louisxsy:你可能還沒定義他們, 08/16 08:18
6F:→ Louisxsy:Dim a as long 08/16 08:18
7F:→ Louisxsy:就這樣,還有你那If我看也改Select比較快 08/16 08:18
8F:→ Louisxsy:然後只能說這文... 08/16 08:18
9F:→ tsongs:只能說給新手這範例很不好 08/16 11:35
10F:→ tsongs:交元件語法還套需要跳來跳去想的邏輯 08/16 11:36
11F:→ tsongs:教 08/16 11:36