| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 3564 人关注过本帖
标题:用vb.net编写的猜数字游戏
取消只看楼主 加入收藏
guyan1220
Rank: 1
等 级:新手上路
帖 子:100
专家分:0
注 册:2006-5-22
收藏
 问题点数:0 回复次数:5 
用vb.net编写的猜数字游戏
希望有vb.net兴趣的人加我QQ:109501246 邮箱:guizhongyingjigzj@3126.com
有vb.net编的猜数字游戏
EbR97m6u.rar (12.64 KB) 用vb.net编写的猜数字游戏


搜索更多相关主题的帖子: 数字 游戏 编写 
2006-05-22 16:34
guyan1220
Rank: 1
等 级:新手上路
帖 子:100
专家分:0
注 册:2006-5-22
收藏
得分:0 
为什么没人 发表意见呢
2006-05-23 09:31
guyan1220
Rank: 1
等 级:新手上路
帖 子:100
专家分:0
注 册:2006-5-22
收藏
得分:0 

猜大小 会有提示 代码如下:
Public Class Form1
Inherits System.Windows.Forms.Form

Dim num As Integer = -1, str As String, tsum As Integer

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsure.Click
If num = -1 Then
MsgBox("您还没有点击开始!", MsgBoxStyle.Critical, "系统提示")
Exit Sub
End If
If tsum = 0 Then
MsgBox("时间已到,请重新开始!", MsgBoxStyle.OKOnly, "系统提示")
Exit Sub
End If
If txtnum.Text < "0 " Or txtnum.Text > "9999" Then
Labanser.ForeColor = ColorTranslator.FromOle(QBColor(15))
Labanser.Text = "您输入的数字超出了范围!"
txtnum.Text = ""
ElseIf Val(txtnum.Text) > num Then
Labanser.ForeColor = ColorTranslator.FromOle(QBColor(14))
Labanser.Text = "数字" & txtnum.Text & "太大了!"
txtnum.Text = ""
ElseIf Val(txtnum.Text) < num Then
Labanser.ForeColor = ColorTranslator.FromOle(QBColor(10))
Labanser.Text = "数字 " & txtnum.Text & " 太小了!"
txtnum.Text = ""
ElseIf Val(txtnum.Text) = num Then
Labanser.ForeColor = ColorTranslator.FromOle(QBColor(11))
Labanser.Text = "恭喜您猜对了!"
Timer3.Enabled = False
End If
Timer1.Enabled = True
End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If Labanser.Left > 85 Then
Labanser.Left = Labanser.Left - 3
Else : Labanser.Left = 304
Timer1.Enabled = False
txtnum.Focus()
End If
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
cai.Left = 144 : cai.Top = 0 : shu.Left = -48 : shu.Top = 96 : zi.Left = 304 : zi.Top = 96
tw1.Enabled = True
tsum = 0
rb1.Checked = True
Timer1.Enabled = False
Timer4.Enabled = True
Labanser.Left = 304 : Labanser.Top = 96
End Sub
Private Sub tw1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tw1.Tick
If cai.Left = 144 And cai.Top < 96 Then
cai.Top = cai.Top + 3
ElseIf cai.Left = 144 And cai.Top = 96 Then
tw1.Enabled = False
tw2.Enabled = True
End If
End Sub
Private Sub tw2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tw2.Tick
If shu.Top = 96 And shu.Left < 144 Then
shu.Left = shu.Left + 6
ElseIf shu.Top = 96 And shu.Left = 144 Then
tw2.Enabled = False
tw3.Enabled = True
End If
End Sub
Private Sub tw3_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tw3.Tick
If zi.Top = 96 And zi.Left > 144 Then
zi.Left = zi.Left - 8
ElseIf zi.Left = 144 And zi.Top = 96 Then
tw3.Enabled = False
topen.Enabled = True
topen1.Enabled = True
End If
End Sub
Private Sub topen_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles topen.Tick
If cai.Left > 96 And cai.Top = 96 Then
cai.Left = cai.Left - 2
ElseIf cai.Left = 96 And cai.Top = 96 Then
topen.Enabled = False
End If
End Sub
Private Sub topen1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles topen1.Tick
If zi.Top = 96 And zi.Left < 192 Then
zi.Left = zi.Left + 2
ElseIf zi.Left = 192 And zi.Top = 96 Then
topen1.Enabled = False
End If
End Sub
Private Sub btnstar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnstar.Click
tw1.Enabled = False : tw2.Enabled = False : tw3.Enabled = False : Timer4.Enabled = False
cai.Visible = False : shu.Visible = False : zi.Visible = False
Timer3.Enabled = True
If rb1.Checked = True Then
tsum = 81
ElseIf rb2.Checked = True Then
tsum = 61
ElseIf rb3.Checked = True Then
tsum = 41
End If
Randomize()
num = Int(Rnd() * 10000)
txtnum.Text = ""
txtnum.Focus()
End Sub

Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
Label3.Text = TimeOfDay
End Sub

Private Sub Timer3_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer3.Tick
tsum = tsum - 1
Label2.Text = "还剩" & tsum & "秒"
If tsum = 0 Then
Timer3.Enabled = False
MsgBox("时间到!", MsgBoxStyle.OKOnly, "系统提示")
Labanser.ForeColor = ColorTranslator.FromOle(QBColor(0))
Labanser.Text = "正确的数字是:" & num & ""
Timer1.Enabled = True
Label2.Text = ""
Timer3.Enabled = False
End If
End Sub

Private Sub btnexit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnexit.Click
End
End Sub
Dim x As Integer = 0
Private Sub Timer4_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer4.Tick

If topen.Enabled = False And topen1.Enabled = False Then
x = x + 1
End If
If x = 2 Then
cai.Visible = False
shu.Visible = False
zi.Visible = False
x = 0
tw1.Enabled = True
cai.Left = 144 : cai.Top = 0 : shu.Left = -48 : shu.Top = 96 : zi.Left = 304 : zi.Top = 96
cai.Visible = True : shu.Visible = True : zi.Visible = True
End If
End Sub
End Class

2006-05-25 22:28
guyan1220
Rank: 1
等 级:新手上路
帖 子:100
专家分:0
注 册:2006-5-22
收藏
得分:0 
如果有问题的话给我留言
2006-06-05 13:32
guyan1220
Rank: 1
等 级:新手上路
帖 子:100
专家分:0
注 册:2006-5-22
收藏
得分:0 
对不起 前几天有事 tw1 tw2 tw3 分别控制三个字的动作 topen控制那三个字的展开动作 label3是显示当前的时间
由于作的仓促没有给控件命好名 实在抱歉
2006-07-10 11:55
guyan1220
Rank: 1
等 级:新手上路
帖 子:100
专家分:0
注 册:2006-5-22
收藏
得分:0 
不需要什么支持呀   你是不是没有装visual
2006-07-10 17:16
快速回复:用vb.net编写的猜数字游戏
数据加载中...
 
   



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

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