www.pudn.com > pt.rar > pt.frm
VERSION 5.00
Object = "{27395F88-0C0C-101B-A3C9-08002B2F49FB}#1.1#0"; "PICCLP32.OCX"
Begin VB.Form Form1
BorderStyle = 1 'Fixed Single
Caption = "拼图"
ClientHeight = 3375
ClientLeft = 45
ClientTop = 330
ClientWidth = 2295
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3375
ScaleWidth = 2295
StartUpPosition = 2 '屏幕中心
Begin VB.CommandButton Command2
Caption = "(&A)关于"
Height = 375
Left = 120
TabIndex = 3
Top = 2880
Width = 2055
End
Begin VB.CommandButton Command1
Caption = "(&P)play"
Height = 300
Left = 0
TabIndex = 0
Top = 0
Width = 855
End
Begin PicClip.PictureClip PictureClip1
Left = 2280
Top = 480
_ExtentX = 3122
_ExtentY = 4101
_Version = 393216
Rows = 3
Cols = 3
Picture = "pt.frx":0000
End
Begin VB.Label Label2
Caption = "0"
Height = 255
Left = 1560
TabIndex = 2
Top = 0
Width = 1815
End
Begin VB.Label Label1
Caption = "步数:"
Height = 255
Left = 960
TabIndex = 1
Top = 0
Width = 1815
End
Begin VB.Image Image1
Height = 735
Index = 8
Left = 1560
Top = 2040
Width = 615
End
Begin VB.Image Image1
Height = 735
Index = 7
Left = 1560
Top = 1200
Width = 615
End
Begin VB.Image Image1
Height = 735
Index = 6
Left = 1560
Top = 360
Width = 615
End
Begin VB.Image Image1
Height = 735
Index = 5
Left = 840
Top = 2040
Width = 615
End
Begin VB.Image Image1
Height = 735
Index = 4
Left = 840
Top = 1200
Width = 615
End
Begin VB.Image Image1
Height = 735
Index = 3
Left = 840
Top = 360
Width = 615
End
Begin VB.Image Image1
Height = 735
Index = 2
Left = 120
Top = 2040
Width = 615
End
Begin VB.Image Image1
Height = 735
Index = 1
Left = 120
Top = 1200
Width = 615
End
Begin VB.Image Image1
Height = 735
Index = 0
Left = 120
Top = 360
Width = 615
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim i As Integer
Dim j As Integer
Dim step As Integer
Dim x(8) As Integer
Dim z As Integer
Private Sub Command1_Click()
init
Command1.Enabled = False
End Sub
Private Sub Command2_Click()
Form2.Show
End Sub
Private Sub Form_Load()
Randomize
End Sub
Sub init()
For i = 0 To 7
a0: x(i) = Int(Rnd * 8)
For j = 0 To i - 1
If x(i) = x(j) Then GoTo a0
Next
Next
For i = 0 To 7
Image1(i).Enabled = True
Image1(x(i)).Picture = PictureClip1.GraphicCell(i)
Next
Image1(8).Picture = LoadPicture("")
End Sub
Private Sub Image1_Click(Index As Integer)
Select Case Index Mod 3
Case 0
If Image1(Index + 1).Picture = LoadPicture("") Then
Image1(Index + 1).Picture = Image1(Index).Picture
Image1(Index).Picture = LoadPicture("")
win
End If
Case 1
If Image1(Index - 1).Picture = LoadPicture("") Then
Image1(Index - 1).Picture = Image1(Index).Picture
Image1(Index).Picture = LoadPicture("")
win
End If
If Image1(Index + 1).Picture = LoadPicture("") Then
Image1(Index + 1).Picture = Image1(Index).Picture
Image1(Index).Picture = LoadPicture("")
win
End If
Case 2
If Image1(Index - 1).Picture = LoadPicture("") Then
Image1(Index - 1).Picture = Image1(Index).Picture
Image1(Index).Picture = LoadPicture("")
win
End If
End Select
Select Case Index \ 3
Case 0
If Image1(Index + 3).Picture = LoadPicture("") Then
Image1(Index + 3).Picture = Image1(Index).Picture
Image1(Index).Picture = LoadPicture("")
win
End If
Case 1
If Image1(Index - 3).Picture = LoadPicture("") Then
Image1(Index - 3).Picture = Image1(Index).Picture
Image1(Index).Picture = LoadPicture("")
win
End If
If Image1(Index + 3).Picture = LoadPicture("") Then
Image1(Index + 3).Picture = Image1(Index).Picture
Image1(Index).Picture = LoadPicture("")
win
End If
Case 2
If Image1(Index - 3).Picture = LoadPicture("") Then
Image1(Index - 3).Picture = Image1(Index).Picture
Image1(Index).Picture = LoadPicture("")
win
End If
End Select
End Sub
Sub win()
Dim num As Integer
step = step + 1
Label2.Caption = step
For i = 0 To 8
If Image1(i).Picture = PictureClip1.GraphicCell(i) Then num = num + 1
Next
If num >= 8 Then
MsgBox "very good!"
For i = 0 To 8
Image1(i).Enabled = False
Next
Command1.Enabled = True
End If
End Sub