| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 666 人关注过本帖
标题:菜鸟求助数字游戏的问题
只看楼主 加入收藏
wsllsg
Rank: 1
来 自:浙江杭州
等 级:新手上路
帖 子:16
专家分:0
注 册:2008-7-23
收藏
 问题点数:0 回复次数:3 
菜鸟求助数字游戏的问题
图片附件: 游客没有浏览图片的权限,请 登录注册
我想让四个数字分别1秒加一次,可是这代码写好后四个数字隔一秒不是+1而是+好多。。。。。
4个intervel属性为1000,求助大虾们怎么改下代码




Dim i As Integer, number As Integer
Private Sub Command1_Click()
Command2.Enabled = True
Command3.Enabled = True
Command4.Enabled = True
Command5.Enabled = True
Timer1.Enabled = True
Timer2.Enabled = True
Timer3.Enabled = True
Timer4.Enabled = True
Command1.Caption = Format(Int(Rnd * 10000), "0000")
Command1.Enabled = False
End Sub

Private Sub Command2_Click()
Timer1.Enabled = False
If Not (Timer1.Enabled Or Timer2.Enabled Or Timer3.Enabled Or Timer4.Enabled) Then
number = Label1.Caption * 1000 + Label2.Caption * 100 + Label3.Caption * 10 + Label4.Caption
If Command1.Caption = number Then
MsgBox "你真强"
End If
Command1.Caption = "开始"
Command1.Enabled = True
End If
End Sub
Private Sub Command3_Click()
Timer2.Enabled = False
If Not (Timer1.Enabled Or Timer2.Enabled Or Timer3.Enabled Or Timer4.Enabled) Then
number = Label1.Caption * 1000 + Label2.Caption * 100 + Label3.Caption * 10 + Label4.Caption
If Command1.Caption = number Then
MsgBox "你真强"
End If
Command1.Caption = "开始"
Command1.Enabled = True
End If
End Sub
Private Sub Command4_Click()
Timer3.Enabled = False
If Not (Timer1.Enabled Or Timer2.Enabled Or Timer3.Enabled Or Timer4.Enabled) Then
number = Label1.Caption * 1000 + Label2.Caption * 100 + Label3.Caption * 10 + Label4.Caption
If Command1.Caption = number Then
MsgBox "你真强"
End If
Command1.Caption = "开始"
Command1.Enabled = True
End If
End Sub

Private Sub Command5_Click()
Timer4.Enabled = False
If Not (Timer1.Enabled Or Timer2.Enabled Or Timer3.Enabled Or Timer4.Enabled) Then
number = Label1.Caption * 1000 + Label2.Caption * 100 + Label3.Caption * 10 + Label4.Caption
If Command1.Caption = number Then
MsgBox "你真强"
End If
Command1.Caption = "开始"
Command1.Enabled = True
End If
End Sub



Private Sub Timer1_Timer()
Label1.Caption = i
If i = 9 Then
i = 0
Else
i = i + 1
End If
End Sub

Private Sub Timer2_Timer()
Label2.Caption = i
If i = 9 Then
i = 0
Else
i = i + 1
End If
End Sub
Private Sub Timer3_Timer()
Label3.Caption = i
If i = 9 Then
i = 0
Else
i = i + 1
End If
End Sub
Private Sub Timer4_Timer()
Label4.Caption = i
If i = 9 Then
i = 0
Else
i = i + 1
End If
End Sub
搜索更多相关主题的帖子: 数字 游戏 
2008-09-05 19:20
不说也罢
Rank: 13Rank: 13Rank: 13Rank: 13
等 级:贵宾
威 望:39
帖 子:1481
专家分:4989
注 册:2007-10-7
收藏
得分:0 
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim l As Integer''''四个定时器不能只定义一个i变量,需要四个,每个定时器使用一个,再研究下面代码中定时器事件里面代码,其它无需变动
Dim number As Integer
Private Sub Command1_Click()
  Command2.Enabled = True
  Command3.Enabled = True
  Command4.Enabled = True
  Command5.Enabled = True
  Timer1.Enabled = True
  Timer2.Enabled = True
  Timer3.Enabled = True
  Timer4.Enabled = True
  Command1.Caption = Format(Int(Rnd * 10000), "0000")
  Command1.Enabled = False
End Sub

Private Sub Command2_Click()
  Timer1.Enabled = False
  If Not (Timer1.Enabled Or Timer2.Enabled Or Timer3.Enabled Or Timer4.Enabled) Then
  number = Label1.Caption * 1000 + Label2.Caption * 100 + Label3.Caption * 10 + Label4.Caption
  If Command1.Caption = number Then
  MsgBox "你真强"
  End If
  Command1.Caption = "开始"
  Command1.Enabled = True
End If
End Sub
Private Sub Command3_Click()
  Timer2.Enabled = False
  If Not (Timer1.Enabled Or Timer2.Enabled Or Timer3.Enabled Or Timer4.Enabled) Then
    number = Label1.Caption * 1000 + Label2.Caption * 100 + Label3.Caption * 10 + Label4.Caption
  If Command1.Caption = number Then
    MsgBox "你真强"
  End If
 Command1.Caption = "开始"
 Command1.Enabled = True
End If
End Sub
Private Sub Command4_Click()
Timer3.Enabled = False
If Not (Timer1.Enabled Or Timer2.Enabled Or Timer3.Enabled Or Timer4.Enabled) Then
number = Label1.Caption * 1000 + Label2.Caption * 100 + Label3.Caption * 10 + Label4.Caption
If Command1.Caption = number Then
MsgBox "你真强"
End If
Command1.Caption = "开始"
Command1.Enabled = True
End If
End Sub

Private Sub Command5_Click()
Timer4.Enabled = False
If Not (Timer1.Enabled Or Timer2.Enabled Or Timer3.Enabled Or Timer4.Enabled) Then
number = Label1.Caption * 1000 + Label2.Caption * 100 + Label3.Caption * 10 + Label4.Caption
If Command1.Caption = number Then
MsgBox "你真强"
End If
Command1.Caption = "开始"
Command1.Enabled = True
End If
End Sub



Private Sub Timer1_Timer()
Label1.Caption = i
If i = 9 Then
i = 0
Else
i = i + 1
End If
End Sub

Private Sub Timer2_Timer()
Label2.Caption = j
If j = 9 Then
j = 0
Else
j = j + 1
End If
End Sub
Private Sub Timer3_Timer()
Label3.Caption = k
If k = 9 Then
k = 0
Else
k = k + 1
End If
End Sub
Private Sub Timer4_Timer()
Label4.Caption = l
If l = 9 Then
l = 0
Else
l = l + 1
End If
End Sub

===================================================
讨厌C#的行尾的小尾巴;和一对大括号{ }
===================================================
2008-09-05 20:17
不说也罢
Rank: 13Rank: 13Rank: 13Rank: 13
等 级:贵宾
威 望:39
帖 子:1481
专家分:4989
注 册:2007-10-7
收藏
得分:0 
其实上面的代码简单加工一下,在窗体的load事件中使每一个标签控件显示的是随机数,就类似于一个抽奖程序了

===================================================
讨厌C#的行尾的小尾巴;和一对大括号{ }
===================================================
2008-09-05 20:25
wsllsg
Rank: 1
来 自:浙江杭州
等 级:新手上路
帖 子:16
专家分:0
注 册:2008-7-23
收藏
得分:0 
哈哈,问题解决了,谢谢你!原来每个timer的计数器都要自己定义一个,学习到了!!

にㄐ我很乖、С又不ㄇ坏,Ч善ō良┞又可∧τ爱!
2008-09-05 21:24
快速回复:菜鸟求助数字游戏的问题
数据加载中...
 
   



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

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