看不懂啊,我上高一,这是我们信息老师留的作业,还有统计才几次呢
追答奥,高一学生啊,那简化下:
窗体上放text1,label1,打开代码窗口,复制下列代码:
Private Num As Integer
Private Sub Form_Load()
Num = Rnd() * 100 + 1 '产生1-100随机数,Rnd()产生的数x,0= Num) Then
Label1.Caption = "您输入的数大了"
ElseIf (Text1.Text < Num) Then
Label1.Caption = "您输入的数小了"
Else
Label1.Caption = "恭喜,您猜对了!"
End If
End If
End Sub
我们就学了这一个 Private Sub Command1_Click()
追答窗体上放两个command1和command2,一个text1,一个label1;command1、command2的caption属性设置成:“出一个数” 和 “我猜”,text1的text属性设成空白,复制如下代码到代码窗口:
Private Num As Integer
Private Sub Command1_Click()
Num = Rnd() * 100 + 1 '产生1-100随机数,Rnd()产生的数x,0= Num) Then
Label1.Caption = "您输入的数大了"
ElseIf (Text1.Text < Num) Then
Label1.Caption = "您输入的数小了"
Else
Label1.Caption = "恭喜,您猜对了!"
End If
End Sub
运行后,先点击“出一个数”,在text空白处输入你猜想的数,然后点击“我猜”,没猜对,删除以前输入text里的数,重新输入再试
这回该满意了吧
求VB小游戏,简单一点,越简单越好
Private Sub Label1_DragDrop(Source As Control, x As Single, y As Single) Dim Label1X As Integer '记录空白控件Label1左上角X的位置 Dim Label1Y As Integer '记录空白控件Label1左上角Y的位置 Dim flag(3) As Boolean '获取空白控件Label1的位置 Label1X = Label1.Left Label1Y = Label1.Top ...
vb程序 1到50生成随机排序后输出
Private Sub Command1_Click()Dim a(100) As Integer Randomize For i = 1 To 100 a(i) = Int(100 * Rnd)Print a(i);If i Mod 20 = 0 Then Print Next i For i = 1 To 99 For j = 1 To 100 - i If a(j) > a(j + 1) Then t = a(j): a(j) = a(j + 1):...
VB代码,计算机随机产生10个1—100的奇数,并由大到小输出
Private Sub Form_Load()Me.Show Dim a(10) As Integer Print "随机产生的10个1-100的奇数:"Randomize For i = 1 To 10 a(i) = Int(100 * Rnd + 1)If a(i) Mod 2 = 0 Then a(i) = a(i) + 1 Print a(i);Next Print Print "从大到小排列:"For i = 1 To 9 For ...
vb程序设计:随机产生一个三位正整数,然后逆序输出该数,产生的数与逆序...
Private Sub Form_Click()Dim x As IntegerDim n1 As String, n2 As String, n3 As StringRandomizex = Int(Rnd * 900) + 100n1 = Left(x, 1)n2 = Mid(x, 2, 1)n3 = Right(x, 1)Print x, Val(n3 & n2 & n1)End Sub补充一种最简单的直接函数逆序法:Private Sub Form_Click...
用VB如何写1到100之间所有能被3整除而不能被7整除的整数的和与个数的...
VB代码如下:Dim i, jj = 0For i = 1 To 100If (i Mod 3 = 0 Or i Mod 7 = 0) And i Mod 21 <> 0 ThenPrint i,j = j + 1If j = 7 ThenPrintj = 0End IfEnd IfNext i
VB 猜数字编程...
i = 1: s = 0 Else cmdGuess.Enabled = False End If End If Loop txtShow.Text = "你一共猜了" & s & "次电脑生成的那个数是" & RndNum End Sub Private Sub Form_Load()Randomize (Timer)RndNum = Fix((100 - 1 + 1) * Rnd() + 1)txtShow.Text = "电脑已经随机生成了...
VB.net设计一个程序:随机一串字符(abc···),打字,后弹出小窗口(时间...
像这样的情况都属于程序自身的BUG,你往往可在特定的操作顺序下重现错误。无效指针不一定总是0,因此错误提示中的内存地址也不一定为“0x00000000”,而是其他随机数字。如果系统经常有所提到的错误提示,下面的建议可能会有帮助:1.查看系统中是否有木马或病毒。这类程序为了控制系统往往不负责任地修改系统...
vb任意输入3个整数,按照由小到大排序输出。
用户的这一行 If a > b > c Then是错误的,任何一门语言都是按照运算符优先级从左至右依次计算得出结果的,显然两个>运算符优先级是相同的,所以从左至右依次算。可以参考以下代码:Dim a As Single, b As Single, c As Single a = Text1.Text b = Text2.Text c = Text3.Text '无...
用vb设计与电脑猜剪刀,石头,布的简单程序
MsgBox "你出的是" & tmpstr2 & ",计算机出的是石头," & tmpStr Case 2 If i = 1 Then tmpStr = "你赢了!"If i = 2 Then tmpStr = "平局!"If i = 3 Then tmpStr = "你输了!"MsgBox "你出的是" & tmpstr2 & ",计算机出的是剪刀," & tmpStr Case 3 If i = 2...
求大神帮做一个vb四则运算测试的程序,是计算机大作业
Label3下方添加一个Label4 Label2下方添加两个按钮 Command1标题为 "下一题"Command2标题为 "重来"如图:在Form1中添加代码:'Private Type OPER i As Integer k As Integer a As Integer b As Integer p As String c As SingleEnd Type Dim OP() As OPER, n As Integer...