vb编程设计计算器实验报告_第1页
vb编程设计计算器实验报告_第2页
vb编程设计计算器实验报告_第3页
全文预览已结束

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、vb编程设计扫雷实验报告一 设计名称:扫雷二 设计目的:通过vb程序设计出类似游戏“扫雷”的程序。三 vb设计扫雷游戏界面:四设计步骤:1. 新建一个工程2. 设置控件添加command1控件数组,控件数组内个数为99。添加command2控件,caption属性设置为“开始”添加timer控件,设置interval属性值为“1000”添加label1,label2控件,设置caption属性分别为“雷数”,“计时”添加text1,text2控件,设置text属性为“20”3. 编写代码3private sub command1_mousedown(index as integer, butt

2、on as integer, shift as integer, x as single, y as single)if button = 1 then if command1(index).tag = true then msgbox gameover! timer1.enabled = false text2 = 0 else m = 0 select case index case 0 if command1(index + 1).tag = true then m = m + 1 if command1(index + 10).tag = true then m = m + 1 if

3、command1(index + 11).tag = true then m = m + 1 case 9 if command1(index - 1).tag = true then m = m + 1 if command1(index + 10).tag = true then m = m + 1 if command1(index + 9).tag = true then m = m + 1 case 90 if command1(index + 1).tag = true then m = m + 1 if command1(index - 10).tag = true then m

4、 = m + 1 if command1(index - 9).tag = true then m = m + 1 case 99 if command1(index - 1).tag = true then m = m + 1 if command1(index - 10).tag = true then m = m + 1 if command1(index - 11).tag = true then m = m + 1 case 1 to 8 if command1(index + 1).tag = true then m = m + 1 if command1(index - 1).t

5、ag = true then m = m + 1 if command1(index + 10).tag = true then m = m + 1 if command1(index + 9).tag = true then m = m + 1 if command1(index + 11).tag = true then m = m + 1 case 91 to 98 if command1(index + 1).tag = true then m = m + 1 if command1(index - 1).tag = true then m = m + 1 if command1(in

6、dex - 10).tag = true then m = m + 1 if command1(index - 9).tag = true then m = m + 1 if command1(index - 11).tag = true then m = m + 1 case 10, 20, 30, 40, 50, 60, 70, 80 if command1(index + 10).tag = true then m = m + 1 if command1(index - 10).tag = true then m = m + 1 if command1(index + 1).tag =

7、true then m = m + 1 if command1(index - 9).tag = true then m = m + 1 if command1(index + 11).tag = true then m = m + 1 case 19, 29, 39, 49, 59, 69, 79, 89 if command1(index + 10).tag = true then m = m + 1 if command1(index - 10).tag = true then m = m + 1 if command1(index - 1).tag = true then m = m

8、+ 1 if command1(index + 9).tag = true then m = m + 1 if command1(index - 11).tag = true then m = m + 1 case else if command1(index + 10).tag = true then m = m + 1 if command1(index - 10).tag = true then m = m + 1 if command1(index + 1).tag = true then m = m + 1 if command1(index + 9).tag = true then

9、 m = m + 1 if command1(index + 11).tag = true then m = m + 1 if command1(index - 1).tag = true then m = m + 1 if command1(index - 9).tag = true then m = m + 1 if command1(index - 11).tag = true then m = m + 1 end select command1(index).caption = m end ifend ifif button = 2 then if command1(index).ta

10、g = true then command1(index).caption = * text1 = val(text1) - 1 else command1(index).caption = ? end ifend ifend subprivate sub command2_click()timer1.enabled = truetext2 = 0randomizefor i = 0 to 99command1(i).tag = falsecommand1(i).caption = nextfor i = 1 to val(text1)k = int(rnd * 100)if command1(k).tag = true theni = i - 1elsecommand1(k).tag = trueend if

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论