VB猜数字游戏源代码?
Public?Class?Form1
Dim?b?As?Integer
Dim?js?As?Integer
Private?Sub?Button1_Click(ByVal?sender?As?System.Object,?ByVal?e?As?System.EventArgs)?Handles?Button1.Click
If?Me.Button1.Text?=?"开始"?Then
Dim?a?As?Integer?=?MsgBox("游戏开始你准备好了吗",?MsgBoxStyle.YesNo,?"提示!")
If?a?=?6?Then
js?=?1
Me.Button1.Text?=?"确定"
Me.Button2.Text?=?"返回"
Me.Label2.Text?=?"我这里有1~10的正整数猜猜是多少"
Me.TextBox1.Visible?=?True
Randomize()
b?=?Int(Rnd()?*?9?+?1)
Else
Exit?Sub
End?If
Else
If?Me.TextBox1.Text.Trim?=?""?Or?Asc(Me.TextBox1.Text)?<?19?Or?Asc(Me.TextBox1.Text)?>?57?Then
MsgBox("请输入数字")
Exit?Sub
Else
If?js?=?3?Then
MsgBox("对不起,你已经超过3次,请重新开始")
Me.Button1.Text?=?"开始"
Me.Button2.Text?=?"退出"
Me.TextBox1.Visible?=?False
Me.Label2.Text?=?""
Else
If?Me.TextBox1.Text?=?b?Then
Me.Label2.Text?=?"你真幸运猜对了"
Me.Button1.Visible?=?False
Me.Button2.Visible?=?False
Me.Button3.Visible?=?True
ElseIf?TextBox1.Text?>?b?Then
js?+=?1
Me.TextBox1.Text?=?""
Me.Label2.Text?=?"你的数据太大了,请重新猜吧,注意只允许猜3次"
ElseIf?TextBox1.Text?<?b?Then
js?+=?1
Me.TextBox1.Text?=?""
Me.Label2.Text?=?"你的数据太小了,请重新猜吧,注意只允许猜3次"
End?If
End?If
End?If
End?If
End?Sub
Private?Sub?Button3_Click(ByVal?sender?As?System.Object,?ByVal?e?As?System.EventArgs)?Handles?Button3.Click
Me.Button1.Text?=?"开始"
Me.Button2.Text?=?"返回"
Me.TextBox1.Text?=?""
Me.Button3.Visible?=?False
Me.TextBox1.Visible?=?False
Me.Label2.Text?=?""
Me.Button1.Visible?=?True
Me.Button2.Visible?=?True
End?Sub
End?Class
刚才试了在VB里编译通过
如果你需要的话我传给你