| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 787 人关注过本帖
标题:各位,我做了一个猜字小游戏,里面的的程序老是提示错误!请大家指点以下
取消只看楼主 加入收藏
绕花玉蝴蝶
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2005-6-20
收藏
 问题点数:0 回复次数:0 
各位,我做了一个猜字小游戏,里面的的程序老是提示错误!请大家指点以下

Dim PcA, PcB, PcC, PcD As Integer '电脑给出的每一位数 Dim UserA, UserB, UserC, UserD As Integer '每一位数 Dim Degree As Integer '拥护猜了几次 Dim Num As Integer '判断用户输入次数的变量

Private Sub Command1_Click(index As Integer) '用户输入时 '使用输入过的按钮无效 If Num >= 4 Then Command1(index).Enabled = False End If '判断用户输入了几位,如果输入了四位则确认按钮有效 If Num = 4 Then Command2.Enabled = True End If End Sub

Private Sub Command2_Click() '单击确认按钮 '判断用户是否输入正确 Dim A, B As Integer A = o B = o Degree = Degree + 1 If UserA = PcA Then A = A + 1 ElseIf UserA = PcB Or UserA = PcC Or UserA = PcD Then B = B + 1 End If If UserB = PcB Then A = A + 1 ElseIf UserB = PcA Or UserB = PcC Or UserB = PcD Then B = B + 1 End If If UserC = PcC Then A = 1 + 1 ElseIf UserC = PcA Or UserC = PcB Or UserC = PcD Then B = 1 End If If UserD = PcD Then A = A + 1 ElseIf UserD = PcA Or UserD = PcB Or UserC = PcC Then B = B + 1 End If '显示提示 Label1.Caption = A & "A" & B & "B" List1.Addltem UserA & UserB & UserC & UserD & "" & Label1.Caption '初始化输入按钮 If A = 4 Then MsgBox "你猜对了!" & "你一共猜对了" & Degree & "次" For i = o To 9 Command1(i).Enabled = False Next i Command2.Enabled = False End If

End Sub

Private Sub Command3_Click() '单击取消按钮时 Num = 1 For i = o To 9 Command1(i).Enabled = True Next i Command2.Enabled = False

End Sub

Private Sub End_Click(index As Integer) '游戏结束时 End

End Sub

Private Sub Form_Load() '程序运行时 '初始化 For i = 0 To 9 Command1(i).Enabled = False Next i Command2.enbled = False Command3.enbled = False View.enbled = False End Sub

Private Sub List1_Click() '取得用户输入 Select Case index Case 0 UserEnter (0) '调用UserEnter过程 Case1 UserEnter(1) Case2 UserEnter(2) Case3 UserEnter(3) Case4 UserEnter(4) Case5 UserEnter(5) Case6 UserEnter(6) Case7 UserEnter(7) Case8 UserEnter(8) Case9 UserEnter(9) End Select End Sub

End Sub

Private Sub New_Click(index As Integer) '开始一个新游戏 View Enabled = True '可以看答案 List1.Clear '清空列表框 Degree = 0 '对随机数生成器做初始化 Randomize Num = 1 Label1 = 0 & "a" & 0 & "b" '电脑给出的每一位数 PcA = Int(9 * Rnd) PcB = Int(9 * Rnd) Loop While PcB = PcA Do PcC = Int(9 * Rnd) Loop While PcC = PcA Or PcC = PcB Do PcD = Int(9 * Rnd) Loop While PcD = PcA Or PcD = PcB Or PcD = PcC For i = 0 To 9 Command1(i).Enabled = True Next i Command2(i).Enabled = False Command3(i).Enabled = True End Sub

Private Sub View_Click(index As Integer) '显示答案 MsgBox "答案是:" & PcA & PcB & PcC & PcD & "你答对了吗?"

End Sub Sub UserEnter(i) '取得用户输入 If Num = 1 Then UserA = i Num = Num + 1 ElseIf Num = 2 Then UserB = 2 ElseIf Num = 3 Then UserC = i Num = Num + 1 ElseIf Num = 4 Then UserD = i Num = Num + 1 Else: MsgBox "四位数够了!" End If End Sub

End Sub

搜索更多相关主题的帖子: 小游戏 提示 
2005-06-28 00:17
快速回复:各位,我做了一个猜字小游戏,里面的的程序老是提示错误!请大家指点以下
数据加载中...
 
   



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

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