cmd2(i).Visible = True
cmd3(i).Visible = True
cmd4(i).Visible = True
For X = 1 To 10
num(X, 19) = 1
Next X
For X = 1 To 19
num(0, X) = 1
num(11, X) = 1
Next X
bhtx = 1 '定义第一个图形
txjl = Int(Rnd * 7 + 1)
loadtx (txjl)
End Sub
'上述代码为将各个控件进行初始化;且这段代码可以实现设计关键4中的问题。关键代码为上面的两个For语句,将Frame框架周围的二维数组数据都设置为大于0的数,这样只要用If语句就可以控制代码的移动范围。
Private Sub Form_KeyPress(KeyAscii As Integer)
Dim a As Integer
Select Case KeyAscii
Case Asc(Form2.Text1.Text) '向左移动
If num(cmd1(i).Left / cmd1(i).Width, (cmd1(i).Top + cmd1(i).Height) / cmd1(i).Height) = 0 And num(cmd2(i).Left / cmd2(i).Width, (cmd2(i).Top + cmd2(i).Height) / cmd2(i).Height) = 0 And num(cmd3(i).Left / cmd3(i).Width, (cmd3(i).Top + cmd3(i).Height) / cmd3(i).Height) = 0 And num(cmd4(i).Left / cmd4(i).Width, (cmd4(i).Top + cmd4(i).Height) / cmd4(i).Height) = 0 Then
cmd1(i).Move cmd1(i).Left - cmd1(i).Width
cmd2(i).Move cmd2(i).Left - cmd2(i).Width
cmd3(i).Move cmd3(i).Left - cmd3(i).Width
cmd4(i).Move cmd4(i).Left - cmd4(i).Width
End If Case Asc(Form2.Text2.Text) '向右移动
|