Option Explicit
Rem 瀬戸
Dim hx As Integer, hy As Integer '空き位置のパネルの位置
Dim Cx(10) As Integer, Cy(10) As Integer 'パネルの行、列の位置
Private Sub Form_Load()
Visible = True
AutoRedraw = True
Dim i As Integer
ScaleMode = 3
'********** パネル初期化 *********
For i = 0 To 7
Cx(i) = i Mod 3
Cy(i) = i \ 3
Next i
hx = 2: hy = 2
Randomize '乱数を発生させる
For i = 0 To 500
label_mousedown Int(8 * Rnd), 0, 0, 120, 120
Next i
End Sub
'*********マウスダウンでパネルを移動させる*******
Private Sub label_mousedown(index As Integer, button As Integer, _
shift As Integer, X As Single, Y As Single)
Dim d As Integer
If (Cy(index) = hy And (Cx(index) = hx - 1 Or Cx(index) = hx + 1)) Or _
(Cx(index) = hx And (Cy(index) = hy - 1 Or Cy(index) = hy + 1)) Then
Label(index).Move Label(0).Width * hx, Label(0).Height * hy
d = Cx(index): Cx(index) = hx: hx = d
d = Cy(index): Cy(index) = hy: hy = d
End If
End Sub
|
作業
| コントロール | プロパティ | 値 |
|---|---|---|
| Label1 | (オブジェクト名) | Label |
| Index | 0 | |
| Caption | 1 | |
| Font サイズ | 24 | |
| Height | 975 | |
| Width | 975 |
| コントロール | プロパティ | 値 |
|---|---|---|
| Label2 | (オブジェクト名) | Label |
| Index | 1 | |
| Caption | 2 | |
| Font サイズ | 24 | |
| Height | 975 | |
| Width | 975 |
ポイント
注意
発展