急急急!用vb做拼图游戏
OptionExplicitDimjAsIntegerDimstepAsIntegerDimnAsIntegerPrivateSubCommand1_Click()Pic...
Option Explicit
Dim j As Integer
Dim step As Integer
Dim n As Integer
Private Sub Command1_Click()
PictureClip1.Picture = Picture1.Picture
Dim i As Single
For i = 0 To (n - 1)
Image1(i).Enabled = True '使Image1响应鼠标事件
Image1(i).Picture = PictureClip1.GraphicCell(i) '让图片的8个单元分别赋予 8个Image控件
Next
Image1(n - 1).Picture = LoadPicture("") '空位用于移动图片
End Sub
Private Sub Command2_Click()
CommonDialog1.DialogTitle = "打开"
CommonDialog1.Filter = "所有文件(*.*) "
CommonDialog1.ShowOpen
Picture1.Picture = LoadPicture(CommonDialog1.FileName)
End Sub
Private Sub Text1_Change()
Dim k As Integer
k = Text1.Text
If 0 < k < 11 Then
PictureClip1.Rows = k
PictureClip1.Cols = k
End If
End Sub
Private Sub Form_Load()
Dim i As Integer
n = PictureClip1.Rows * PictureClip1.Cols - 1
Image1(0).Move 0, 0
For i = 1 To n
Load Image1(i)
Image1(i).Visible = True
Next
End Sub
Private Sub Image1_Click(Index As Integer) '注意索引值的运用
Select Case Index Mod k '把Image控件分成k列
Case 0 '当鼠标点击第1列时
If Image1(Index + 1).Picture = LoadPicture("") Then '判断右边是否为空
Image1(Index + 1).Picture = Image1(Index).Picture '交换图片
Image1(Index).Picture = LoadPicture("")
End If
If 1 < n < k Then
Case n '当鼠标点击中间列时
If Image1(Index - 1).Picture = LoadPicture("") Then '判断左边是否为空
Image1(Index - 1).Picture = Image1(Index).Picture
Image1(Index).Picture = LoadPicture("")
End If
If Image1(Index + 1).Picture = LoadPicture("") Then '判断右边是否为空
Image1(Index + 1).Picture = Image1(Index).Picture
Image1(Index).Picture = LoadPicture("")
End If
End If
Case k '当鼠标点击第k列时,也就是最后一列
If Image1(Index - 1).Picture = LoadPicture("") Then '判断左边是否为空
Image1(Index - 1).Picture = Image1(Index).Picture
Image1(Index).Picture = LoadPicture("")
End If
End Select
Select Case Index \ k '把9个Image控件分成三行
Case 0 '当鼠标点击第1行时
If Image1(Index + k).Picture = LoadPicture("") Then '判断下边是否为空
Image1(Index + k).Picture = Image1(Index).Picture
Image1(Index).Picture = LoadPicture("")
End If
If 0 < n < k Then
Case n '当鼠标点击中间行时
If Image1(Index - k).Picture = LoadPicture("") Then '判断上边是否为空
Image1(Index - k).Picture = Image1(Index).Picture
Image1(Index).Picture = LoadPicture("")
End If
If Image1(Index + k).Picture = LoadPicture("") Then '判断下边是否为空
Image1(Index + k).Picture = Image1(Index).Picture
Image1(Index).Picture = LoadPicture("")
End If
End If
Case k '当鼠标点击第k行时
If Image1(Index - k).Picture = LoadPicture("") Then '判断上边是否为空
Image1(Index - k).Picture = Image1(Index).Picture
Image1(Index).Picture = LoadPicture("")
End If
End Select
End Sub
界面:两个commandbutton,一个pictureclip,一个picture,一个commondialog,一个image,一个text!要实现的是:一开始运行的时候picture里有一张默认的图片(按commandbutton2可以选择电脑里的图片),按commangbutton1可以使图片分割成n*n份的图片,分别放在image控件里(n是从text里输入的,0<n<11,不输入默认是3*3份)各位帮帮忙,谢谢~~
你们复制下运行试试闹,这个问题是他没分好,就分出一块,我也晕了啊,呜呜,,,明天要交了来着 展开
Dim j As Integer
Dim step As Integer
Dim n As Integer
Private Sub Command1_Click()
PictureClip1.Picture = Picture1.Picture
Dim i As Single
For i = 0 To (n - 1)
Image1(i).Enabled = True '使Image1响应鼠标事件
Image1(i).Picture = PictureClip1.GraphicCell(i) '让图片的8个单元分别赋予 8个Image控件
Next
Image1(n - 1).Picture = LoadPicture("") '空位用于移动图片
End Sub
Private Sub Command2_Click()
CommonDialog1.DialogTitle = "打开"
CommonDialog1.Filter = "所有文件(*.*) "
CommonDialog1.ShowOpen
Picture1.Picture = LoadPicture(CommonDialog1.FileName)
End Sub
Private Sub Text1_Change()
Dim k As Integer
k = Text1.Text
If 0 < k < 11 Then
PictureClip1.Rows = k
PictureClip1.Cols = k
End If
End Sub
Private Sub Form_Load()
Dim i As Integer
n = PictureClip1.Rows * PictureClip1.Cols - 1
Image1(0).Move 0, 0
For i = 1 To n
Load Image1(i)
Image1(i).Visible = True
Next
End Sub
Private Sub Image1_Click(Index As Integer) '注意索引值的运用
Select Case Index Mod k '把Image控件分成k列
Case 0 '当鼠标点击第1列时
If Image1(Index + 1).Picture = LoadPicture("") Then '判断右边是否为空
Image1(Index + 1).Picture = Image1(Index).Picture '交换图片
Image1(Index).Picture = LoadPicture("")
End If
If 1 < n < k Then
Case n '当鼠标点击中间列时
If Image1(Index - 1).Picture = LoadPicture("") Then '判断左边是否为空
Image1(Index - 1).Picture = Image1(Index).Picture
Image1(Index).Picture = LoadPicture("")
End If
If Image1(Index + 1).Picture = LoadPicture("") Then '判断右边是否为空
Image1(Index + 1).Picture = Image1(Index).Picture
Image1(Index).Picture = LoadPicture("")
End If
End If
Case k '当鼠标点击第k列时,也就是最后一列
If Image1(Index - 1).Picture = LoadPicture("") Then '判断左边是否为空
Image1(Index - 1).Picture = Image1(Index).Picture
Image1(Index).Picture = LoadPicture("")
End If
End Select
Select Case Index \ k '把9个Image控件分成三行
Case 0 '当鼠标点击第1行时
If Image1(Index + k).Picture = LoadPicture("") Then '判断下边是否为空
Image1(Index + k).Picture = Image1(Index).Picture
Image1(Index).Picture = LoadPicture("")
End If
If 0 < n < k Then
Case n '当鼠标点击中间行时
If Image1(Index - k).Picture = LoadPicture("") Then '判断上边是否为空
Image1(Index - k).Picture = Image1(Index).Picture
Image1(Index).Picture = LoadPicture("")
End If
If Image1(Index + k).Picture = LoadPicture("") Then '判断下边是否为空
Image1(Index + k).Picture = Image1(Index).Picture
Image1(Index).Picture = LoadPicture("")
End If
End If
Case k '当鼠标点击第k行时
If Image1(Index - k).Picture = LoadPicture("") Then '判断上边是否为空
Image1(Index - k).Picture = Image1(Index).Picture
Image1(Index).Picture = LoadPicture("")
End If
End Select
End Sub
界面:两个commandbutton,一个pictureclip,一个picture,一个commondialog,一个image,一个text!要实现的是:一开始运行的时候picture里有一张默认的图片(按commandbutton2可以选择电脑里的图片),按commangbutton1可以使图片分割成n*n份的图片,分别放在image控件里(n是从text里输入的,0<n<11,不输入默认是3*3份)各位帮帮忙,谢谢~~
你们复制下运行试试闹,这个问题是他没分好,就分出一块,我也晕了啊,呜呜,,,明天要交了来着 展开
舞侠
2024-11-07 广告
2024-11-07 广告
《舞侠OL》全球首款音乐副本网游,既传承音舞游戏经典又实现全面超越。首推带有RPG属性的音乐副本玩法,华丽的明星BOSS阵容,舞蹈属性养成体系,开创了舞蹈技能玩法,使游戏更具有策略性和挑战性,而不再是单纯击打键盘。《舞侠online》游戏采...
点击进入详情页
本回答由舞侠提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询