猜1-10十个数字,只有三次机会,每猜一次提示一次猜了几次还有几次机会,三次机会都没猜中,游戏结束!
还能不能在猜错的时候提示猜的数大了 或者猜的数小了?
VB猜数字游戏程序源代码和思路只可以猜三次
Private Sub Command1_Click()Randomize x = Int(Rnd * 10 + 1)Do While y < 3 y = y + 1 n = Val(InputBox(""))If n = x Then MsgBox "猜对了"Exit Do Else If n > x Then MsgBox "猜大了" & "已猜" & y & "次" & "还有" & 3 - y & "机会"Else MsgBox "猜...
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, "提示...
VB猜字游戏程序代码
end if str=str+chr(13)+b(1)+b(2)+b(3)+b(4)+space(2)+cstr(c)+"A"+cstr(d)+"B"wscript.echo str loop if win=1 then wscript.echo "你猜对了。" else wscript.echo "你没猜对。"\/\/\/ 上面是我写过的一个小游戏。把斜线以上的部分复制到一个文档中,后缀名改为*.vbs,...
VB猜数字游戏程序代码
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.SetFocusRandomize (Timer)Text2 = Int(Rnd() * 10) + 1...
VB制作小游戏源代码
猜数字 建一个文本文档,输入以下代码,后缀改为.frm用vb打开就可以了 以下是程序源码:VERSION 5.00 Begin VB.Form Form1 BorderStyle = 3 'Fixed Dialog Caption = "猜数游戏"ClientHeight = 3900 ClientLeft = 45 ClientTop = 435 ClientWidth = 4680 ...
求VB小游戏代码
猜数字 控件:Text1 - 注意将MultiLine属性修改为True Command1 代码:Private Sub Command1_Click()Randomize Dim Num As Long Dim RightAnswer As Boolean Dim InputNum As Long Text1.Text = ""Num = Int(Rnd * 1000) + 1 RightAnswer = False Text1.Text = Text1.Text + "Here's...
求助!关于用vb写猜数字游戏的代码!网上难找到符合要求的!
Private Sub Command1_Click()Dim n As Integer, i As Integer, a As IntegerRandomizen = Int(Rnd * 100) + 1For i = 1 To 10 a = Val(InputBox("请猜:")) If a = n Then MsgBox "猜中了,恭喜你!" Exit Sub ElseIf a < n Then MsgBox "太小了,继续...
VB中猜数字游戏请高手帮忙啊。
3 s = CInt(InputBox("请输入猜测数字!"))If a = s Then MsgBox ("恭喜你猜对了")End End If If a > s Then MsgBox ("对不起,你猜小了!")End If If a < s Then MsgBox ("对不起,你猜大了!")End If Next i End 这就是主要代码了,至于你说要两个窗体,个人感觉有点多余 ...
帮我用vb编写一个猜数字的小游戏,数字1到100,程序语言3到5行即可.
画个text1和command1 Private Sub Command1_Click()Dim a As Long a = Rnd * 100 MsgBox IIf(a = Val(Text1), "你猜对了,数字是:" & a, "你猜错了,正确答案是:" & a)End Sub
VB猜数字游戏!
建议使用 列表框 listbox ,这样看起来更清晰 代码也做了一些调整,你看看吧:Dim c As Long Private Sub Command1_Click()c = Int(100 * Rnd + 1)End Sub Private Sub CommandOK_Click()Dim b As Long b = Val(InputBox("请输入一个数字(1-100)", "猜数字"))Select Case b Case ...