注册 登录
编程论坛 VB.NET论坛

用vb.net编写的猜数字游戏

guyan1220 发布于 2006-05-22 16:34, 3574 次点击
希望有vb.net兴趣的人加我QQ:109501246 邮箱:guizhongyingjigzj@3126.com
有vb.net编的猜数字游戏
只有本站会员才能查看附件,请 登录

20 回复
#2
guyan12202006-05-23 09:31
为什么没人 发表意见呢
#3
漫漫小生2006-05-23 11:41
你那游戏怎么玩的啊?怎么不懂?
还有源文件呢?

[此贴子已经被作者于2006-5-23 11:41:38编辑过]

#4
wstcl2006-05-23 14:43
以下是引用漫漫小生在2006-5-23 11:41:00的发言:
你那游戏怎么玩的啊?怎么不懂?
还有源文件呢?

就是

#5
guyan12202006-05-25 22:28

猜大小 会有提示 代码如下:
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

#6
但锐2006-06-03 23:49
谢谢~~我选研究研究~~
#7
guyan12202006-06-05 13:32
如果有问题的话给我留言
#8
aristotle2006-06-16 10:45
tw1,tw2,tw3 label3,topen都什么意思啊?
还有猜数字这三个字是怎么实现的?不好意思我是 菜鸟
#9
Ver2006-06-16 12:50
简单
#10
xocy9ck2006-06-20 21:07
我有兴趣,QQ:627792681   我是学习计算机的普通大学生,.
#11
jy025201052006-06-20 21:56
我也有兴趣 QQ184826419
#12
02532DATA2006-06-21 10:36
很简单的算法呀,有必要拿到论坛上来么?行了撒
#13
guyan12202006-07-10 11:55
对不起 前几天有事 tw1 tw2 tw3 分别控制三个字的动作 topen控制那三个字的展开动作 label3是显示当前的时间
由于作的仓促没有给控件命好名 实在抱歉
#14
dragonfly2006-07-10 15:57
为什么在我的电脑上打不开?需要什么支持文件?
#15
guyan12202006-07-10 17:16
不需要什么支持呀   你是不是没有装visual
#16
dragonfly2006-07-11 13:52
是的!
刚下载了一个2005,有空了就安装,学习!
#17
murphy2007-09-16 06:57
简单
#18
wsaaa2007-09-21 21:32
不错,就是时间不够,范围太大了时间太少了
#19
winzc2007-09-22 21:41
先看哈。
#20
adou2007-09-26 15:02

呵呵。

#21
飞雪1112012-11-29 17:13
我加你为好友了
1