| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 578 人关注过本帖
标题:一个简单的仿幸运52的游戏 出的错误
只看楼主 加入收藏
tiancaiak
Rank: 2
等 级:论坛游民
威 望:1
帖 子:111
专家分:43
注 册:2006-9-17
结帖率:100%
收藏
 问题点数:0 回复次数:2 
一个简单的仿幸运52的游戏 出的错误

Dim i, n, j, k, s, prize(1 To 3) As Integer, a() As Integer
Dim sname(1 To 3) As String


Private Sub Command1_Click()
Randomize
n = Int(3 * Rnd) + 1
If i = 0 Then
a(i) = Int(n) '<<<<---------------------------------------------------就是这个地方 它说我下标越界!!
i = i + 1
Timer1.Enabled = True
ElseIf i > 0 Then
Do While 1 <> 0
If i = 3 Then
MsgBox "没有东西了", 0 + 64, "你真强"
End If
For j = 0 To i - 1
If a(j) = n Then
k = 1
End If
Next j
If k = 1 Then
n = 0 * Rnd + 1
ElseIf k = 0 Then
Exit Do
End If
Loop
a(i) = n
i = i + 1
End If
Text1.SetFocus
Text1.Text = ""
Label1.Caption = sname(n)
If n = 1 Then
Image3.Visible = False
Image2.Visible = False
Image1.Visible = True
ElseIf n = 2 Then
Image1.Visible = False
Image3.Visible = False
Image2.Visible = True
ElseIf n = 3 Then
Image2.Visible = False
Image1.Visible = False
Image3.Visible = True
End If
End Sub

Private Sub Command2_Click()
Unload Me
End Sub

Private Sub Command3_Click()
If Text1.Text < prize(n) Then
MsgBox "低了!", 0, "价格"
ElseIf Text1.Text > prize(n) Then
MsgBox "高了!", 0, "价格"
ElseIf Text1.Text = prize(n) Then
MsgBox "恭喜!", 0, "猜对了!"
s = s + prize(n)
Call Command1_Click
End If
End Sub

Private Sub Form_Load()
sname(1) = "电脑"
sname(2) = "手机"
sname(3) = "MP3"
t = 60
i = 0
prize(1) = 8999
prize(2) = 588
prize(3) = 3200
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii < Asc(0) Or KeyAscii > Asc(9) Then
Beep
MsgBox "非法字符", 0, "输入"
KeyAscii = 0
End If
End Sub

Private Sub Timer1_Timer()
Static i As Integer
t = t - 1
Label2.Caption = Str(t) & "秒"
If t = 0 Then
MsgBox "时间到", 0 + 64, "哦,BABY~~"
MsgBox "您得了" & s & "元的东东", 0 + 64, "强"
Timer1.Enabled = False
End If
End Sub

搜索更多相关主题的帖子: 游戏 幸运52 
2006-09-28 20:22
tiancaiak
Rank: 2
等 级:论坛游民
威 望:1
帖 子:111
专家分:43
注 册:2006-9-17
收藏
得分:0 

还望有人救救~~


2006-09-28 20:24
tiancaiak
Rank: 2
等 级:论坛游民
威 望:1
帖 子:111
专家分:43
注 册:2006-9-17
收藏
得分:0 
哦~~ 恩~~ 你这个问题就在于~~~ 恩恩,我知道了,你那个a(),没有再定义,就会出错,改成a(0 to 9)就OK了,呵呵~~
但我就是不给你说,活活活活活

2006-09-29 21:05
快速回复:一个简单的仿幸运52的游戏 出的错误
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.030146 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved