|
楼主 |
发表于 2024-1-26 16:21
|
显示全部楼层
Private Sub UserForm_Initialize()
' 按钮数量 = 3
' 按钮名称 = Array("电子凭证", "撤单", "取消")
' 默认按钮 = 3
Dim i As Integer, ar
窗体宽度 = 282
按钮间距 = 4
左右间距 = 10
ar = 按钮名称
For i = 1 To 按钮数量
With 选择操作方式.Controls.Add("Forms.CommandButton.1")
.Name = "按钮" & i
.Caption = ar(i - 1)
.Width = (窗体宽度 - 12 - (左右间距 * 2) - ((按钮数量 - 1) * 按钮间距)) / 按钮数量
.Left = 左右间距 + (i - 1) * .Width + (i - 1) * 按钮间距
.Top = 15
.Height = 20
Mybtn(i).CtlAdd Me.Controls(.Name), .Caption
End With
Next i
Me.Controls("按钮" & 默认按钮).SetFocus
End Sub
|
|