vb制作扫雷游戏的问题
2个回答
展开全部
见:
自己做了一个:
初始设置:
控件数组Command1() ’通过设置Index=0建立
开始按钮Command2
Const HT = 400 '储存height
Const WT = 400 '储存width
Dim vbRow As Integer
Dim vbLine As Integer
Private Sub Command2_Click()
Command2.Visible = False
Dim cter As Integer
For cter = 1 To 400
Load Command1(cter)
vbRow = Int(cter Mod 20) '列值
If cter Mod 20 = 0 Then vbRow = 20 '如果被20整除说明在第20列,vbRow应该返回20而非0
vbLine = Int(cter \ 20) + 1 '行值
If cter Mod 20 = 0 Then vbLine = vbLine - 1 '如果被20整除,“/”运算返回值将比真实的vbLine多1,应返回vbLine-1
Command1(cter).Height = HT
Command1(cter).Width = WT
Command1(cter).Top = (vbLine - 1) * (HT + 10)
Command1(cter).Left = (vbRow - 1) * (WT + 10)
Command1(cter).Visible = True
DoEvents '防止程序卡死
Next cter
End Sub
Private Sub Form_Load() '用于显示【开始!】按钮(Command2)
Form1.Height = (HT + 10) * 20 + 10
Form1.Width = Form1.Height
Command2.Top = (Form1.Height - Command2.Height) / 2
Command2.Left = (Form1.Width - Command2.Width) / 2
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询