bshy.net
当前位置:首页>>关于vb猜数字游戏编程 要求:让电脑猜一个0-100的数字...的资料>>

vb猜数字游戏编程 要求:让电脑猜一个0-100的数字...

Dim state As Integer '状态 0表示没开始 1表示已开始 Dim min As Integer '最小值 Dim max As Integer '最大值 Dim now As Integer '中值 Dim c As Integer '猜的次数 Private Sub Command1_Click() '开始 state = 1 Guess End Sub Private Sub...

Dim a As Integer a = Int(Rnd() * 100) Dim n As Integer n = 0 Dim m As Integer m = 1 TextBox1.Text = a Do n = InputBox("第" & m & "次了,请猜") If n > a Then MsgBox("太大了") ElseIf n < a Then MsgBox("太小了") Else MsgBox("猜对...

Option ExplicitPrivate Sub Command1_Click()On Error Resume NextDim I As IntegerI = MsgBox("下面游戏开始,你准备好了吗?", vbYesNo)If I = 6 Then Frame1.Visible = True: Text1 = "" Else Frame1.Visible = FalseText1.SetFocusRandomiz...

'两个文字列表框,一个文本框,两个按钮Dim k As BooleanPrivate Sub Command1_Click() '产生一个随机数 Text1 = "" Label1 = "" Label2 = "请在框中输入数字,按回车键猜数" k = False Do While k = False Label1 = Int(100 * Rnd()) '产生的随...

1、我仔细看了下,发现这段语句没什么用: If i = 5 Then Exit Sub End If 因为i=5时,for循环也结束了,所以有没有这段循环都会结束。所以这段代码可以删除了,当然不删也不影响,考虑到代码的质量的话,删去吧。 2、我估计你是想在这里加入一...

先说程序的错误 1.把Int((10 * Rnd) + 1)放到CMD1里 也就是每点一次产生的数都不一样 怎么猜啊 2.没加计数器,不能判断出猜了几次 所以修改后的代码: 加一个按钮CMD2,用来重新产生随机数,进行新一轮猜数 Dim x As Integer, y As Integer, z As...

啥叫用菜单开始程序?是开始游戏哇?就跟蜘蛛纸牌扫雷一样哇?用户是把自己猜的数放在textbox里,还是inputbox?以上均为疑问句……

Dim irnd As IntegerPrivate Sub Command1_Click()irnd = Int(Rnd * 101)End SubPrivate Sub Command2_Click()If Val(Text1.Text) > irnd Then Label1.Caption = "too big"ElseIf Val(Text1.Text) < irnd Then Label1.Caption = "too small"Else...

Private Sub Command1_Click() Dim i As Integer, j As Integer, k As Integer Randomize j = Fix(Rnd * 99) + 1 'Print j Do k = InputBox("请输入你猜的数:", "提示", 0) If k > j Then Print "大了" ElseIf k < j Then Print "小了" Else Pr...

dim a,b as integer a=cint(rnd()*10) b=cint(rnd()*10) dim c as integer '0=退出 ,1=大 ,2=小,3=等于 dim yn as boolean do while c>0 yn=false c=cint(val(inputbox("输入猜测结果,前一个数字是 "+a.tostring(),"输入","0"))) if c>0 then if...

网站首页 | 网站地图
All rights reserved Powered by www.bshy.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com