在窗体中添加以下代码:Option Explicit
Private Sub Command2_Click()Dim i As Integer, j As Integer For i = 0 To 8 Command1(i).Caption = "" '去掉文字 Command1(i).Picture = PictureClip1.GraphicCell(i) Command1(i).Width = PictureClip1.CellWidth * 15 Command1(i).Height = PictureClip1.CellHeight * 15 If i Mod 3 = 0 Then j = j + 1 End If If i Mod 3 <> 0 Then Command1(i).Move Command1(i - 1).Left + Command1(i - 1).Width, Command1(0).Top + (j - 1) * Command1(0).Height Else If i <> 0 Then Command1(i).Move Command1(0).Left, Command1(i - 1).Top + Command1(i - 1).Height End If End If NextEnd Sub
运行:点击转换实际应用中可能将图片分成的块数不一定,所以按钮可以只创建一个(index设为0),然后通过程序动态创建其它按钮。 猜你喜欢