求高手修改 谢谢
Dim A1, B1, C1, D1 As Integer
Dim a, b, c, d As Integer
Private Sub Command1_Click()
Text1.Visible = True
Text2.Visible = True
Text3.Visible = True
Text4.Visible = True
A1 = Int(9 * Rnd)
Do
B1 = Int(9 * Rnd)
Loop While B1 = A1
Do
C1 = Int(9 * Rnd)
Loop While C1 = A1 Or C1 = B1
Do
D1 = Int(9 * Rnd)
Loop While D1 = A1 Or D1 = B1 Or D1 = C1
Text1 = Clear
Text2 = Clear
Text3 = Clear
Text4 = Clear
Label1 = Clear
Label2 = Clear
End Sub
Private Sub Command2_Click()
Dim X, Y As Integer
a = Val(Text1.Text)
b = Val(Text2.Text)
c = Val(Text3.Text)
d = Val(Text4.Text)
If a = A1 Then
X = X + 1
ElseIf a = B1 Or a = C1 Or a = D1 Then
Y = Y + 1
End If
If b = B1 Then
X = X + 1
ElseIf b = A1 Or b = C1 Or d = D1 Then
Y = Y + 1
End If
If c = C1 Then
X = X + 1
ElseIf c = A1 Or c = B1 Or c = D1 Then
Y = Y + 1
End If
If d = D1 Then
X = X + 1
ElseIf d = A1 Or d = B1 Or c = C1 Then
Y = Y + 1
End If
If Text1.Text = Text2.Text Or Text1.Text = Text3.Text Or Text1.Text = Text4.Text Or Text2.Text = Text3.Text Or Text2.Text = Text4.Text Or Text3.Text = Text4.Text Then
Label1.Caption = "禁止重复"
Else: Label1.Caption = X & "X" & Y & "Y"
End If
End Sub
Private Sub Command3_Click()
Label2 = A1 & B1 & C1 & D1
End Sub
用VB语言编写一个猜数字的游戏
首先说一说猜数字这个游戏的玩法,一开始计算机会随机产生一个不重复的四位数,你要输入四位不重复的数与计算机给出的数作对比,如果与计算机给出的数的位置相同数字相同,那么将会是1A,如果数字相同而位置相不同,将会显示1B。例如:计算机的随机数字为:1234 ,我猜的数字为:1356 ,那么这时计算机...
VB猜字游戏程序代码
loop if win=1 then wscript.echo "你猜对了。" else wscript.echo "你没猜对。"\/\/\/ 上面是我写过的一个小游戏。把斜线以上的部分复制到一个文档中,后缀名改为*.vbs,直接双击试试看效果:)参考资料:我的经历
求助!关于用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中猜数字游戏请高手帮忙啊。
As Integer Dim a As Integer Randomize (10)a = Rnd(10)10 For i = 1 To 3 s = CInt(InputBox("请输入猜测数字!"))If a = s Then MsgBox ("恭喜你猜对了")End End If If a > s Then MsgBox ("对不起,你猜小了!")End If If a < s Then MsgBox ("对不起,你猜大了!"...
vb猜数字游戏程序编写
vb猜数字游戏程序编写 20 编写的时候遇到了几个问题,希望可以帮我解决一下 1.怎样用随机函数产生一个1~10之间的整数 2.怎么才能使在输入三次数字后结束程序。 以下是我的代码 Private Sub Command1_Click() Dim x As Integer, y As Integer, z As Integer Dim myvalue myv... 展开 ...
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编写一个猜数字的小游戏,数字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编的猜数字小游戏……不管输入什么数字都显示“数字太大”……求...
Private Sub Form_Load() Randomize a = Int(100 * Rnd + 1)Print "正确答案是:" & a End Sub Private Sub Command1_Click() Dim b As Integer b = Val(InputBox("请输入一个数字(1-100)"))If b > 100 Or b < 1 Then MsgBox ("输入错误!")ElseIf b = a Then MsgBox...
vb里面猜数字游戏问题,新手寻解答??
并且默认初始值为0,解决的办法是把S定义为静态的情况变量,如下:Dim s As Integer 换成 Static s As integer 就可以了。答错了扣分就是在猜错了的判断语句后加上 s -= 10 其中10是你想扣的分,如果你用的VB是6.0的就换成 s = s - 10 ...
VB猜数字游戏!
b = Val(InputBox("请输入一个数字(1-100)", "猜数字"))Select Case b Case Is > 100 Or b < 1:MsgBox "请输入正确的值!"Exit Sub Case c:txt.Text = b & " 恭喜你猜对了!"MsgBox txt.Text, 0, "恭喜"Case Is > c:txt.Text = b & " 太大了!"MsgBox txt.Text, 0, "...