VB编写的工具箱(要像QQ那样有分成 如 好友 一点 就可以张开 )的教程

来源:百度知道 编辑:UC知道 时间:2024/06/24 08:27:25

简单的例子

'一个PictureBox名为Picture1
'Picture1中放一个CommandButton控件数组(本例为16个)
'1200为CommandButton宽度,300为高度,请自行修改为需要的尺寸
Private Sub Form_Load()
Me.WindowState = 2
With Picture1
.Width = 1200 + 60
.Height = 7900
End With
Dim i As Integer
For i = Command1.Count - 1 To 0 Step -1
With Command1(i)
.Width = 1200
.Height = 300
.Top = Picture1.ScaleHeight - 300 * (Command1.Count - i)
.Left = 0
.Caption = "QBColor " & i
End With
Next i
Command1(0).Top = 0
End Sub
'注:如果你在设计时就把各控件的位置及尺寸一一设定好,
'那么上面的代码就可以全部省略了
Private Sub Command1_Click(Index As Integer)
Picture1.SetFocus '把焦点给Picture1是为了不让CommandButton出现难看的黑框
Dim i As Integer
For i = 1 To Index
Command1(i).Top = 300 * i
Next i