作者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