vb小游戏自己做

 时间:2024-10-21 22:33:24

1、打开vb6.0,如图设计Form1界面Form1 的 BorderStyle属性设为3-……Command1 为开始游戏/重置Command2 为 确定Command3 为 退出Command4 为 显示答案Command5 为 清除数字Command6 为 清空提示框Text1至4 为 依次从左到右的4个输入框,设Font属性为宋体,加粗,四号Text5 为 大提示框,Scrollbars属性设置为2-Vertical,MultiLine 属性为trueLabel1 为 显示答案的提示框

vb小游戏自己做

3、Form1中输入代码Private Sub Command2_Click()Dim h As Integer, j As Int髫潋啜缅egerh = 0j = 0If Text1.Text = "" Or Text2.Text = "" Or Text3.Text = "" Or Text4.Text = "" ThenForm2.ShowElseOpen "C:\Users\Administrator\Documents\游戏.txt" For Input As #1d = Input(1, #1)e = Input(1, #1)f = Input(1, #1)g = Input(1, #1)If d <> Text1.Text Thenh = hElse: h = h + 1End IfIf e <> Text2.Text Thenh = hElse: h = h + 1End IfIf f <> Text3.Text Thenh = hElse: h = h + 1End IfIf g <> Text4.Text Thenh = hElse: h = h + 1End IfIf d = Text1.Text Or d = Text2.Text Or d = Text3.Text Or d = Text4.Text Thenj = j + 1End IfIf e = Text1.Text Or e = Text2.Text Or e = Text3.Text Or e = Text4.Text Thenj = j + 1End IfIf f = Text1.Text Or f = Text2.Text Or f = Text3.Text Or f = Text4.Text Thenj = j + 1End IfIf g = Text1.Text Or g = Text2.Text Or g = Text3.Text Or g = Text4.Text Thenj = j + 1End IfText5.Text = Text5.Text & "有" & h & "个位置对了," & "包含" & j & "个相同数字" & vbCrLfEnd IfCloseEnd SubPrivate Sub Command3_Click()EndEnd SubPrivate Sub Command1_Click()Dim w As IntegerDim x As IntegerDim y As IntegerDim z As IntegerText1.Text = ""Text2.Text = ""Text3.Text = ""Text4.Text = ""Label1 = ""Text5.Text = ""Dim b As Stringa = a + 1RandomizeIf a = 0 ThenCommand2.Enabled = FalseElseCommand2.Enabled = TrueEnd Ifw = Int(Rnd() * 9 + 1)x = Int(Rnd() * 9 + 1)y = Int(Rnd() * 9 + 1)z = Int(Rnd() * 9 + 1)Do While w = x Or w = y Or w = z Or x = y Or x = z Or y = zw = Int(Rnd() * 9 + 1)x = Int(Rnd() * 9 + 1)y = Int(Rnd() * 9 + 1)z = Int(Rnd() * 9 + 1)Loopb = w * 1000 + x * 100 + y * 10 + zOpen "C:\Users\Administrator\Documents\游戏.txt" For Output As #1Print #1, bCloseEnd SubPrivate Sub Command4_Click()Dim i As SingleOpen "C:\Users\Administrator\Documents\游戏.txt" For Input As #1i = Input(4, #1)Label1 = iCloseEnd SubPrivate Sub Command5_Click()Text1.Text = ""Text2.Text = ""Text3.Text = ""Text4.Text = ""End SubPrivate Sub Command6_Click()Label1 = ""Text5.Text = ""End SubPrivate Sub Form_Load()Dim a As IntegerIf a = 0 ThenCommand2.Enabled = FalseElseCommand2.Enabled = TrueEnd IfEnd Sub

4、打开“文档”,新建txt文档,重命名“游戏”

  • vb的inputbox函数怎么用?玩转inputbox函数
  • 打开VB代码窗口的几种方法
  • VB入门教程:[21]显示日期
  • vb中array函数用法
  • vb组合框设计时怎么添加列表
  • 热门搜索
    95酒精怎么配成75 脸上起皮怎么办 我的世界狗怎么繁殖 肩膀酸痛怎么办 酸奶机怎么做酸奶 口红怎么涂好看 怎么做目录 炉石传说巫妖王怎么打 计划生育证明怎么开 九牧卫浴怎么样