|
- Private Sub UserForm_Initialize()
- Dim arr, i%, iTop&
- Const iHeight = 24
- arr = Sheet1.Range("C3:D" & Sheet1.Range("C65536").End(3).Row)
- For i = 1 To UBound(arr)
- iTop = (i - 1) * iHeight + 12
- With Me.Controls.Add("Forms.Label.1", "Label" & i, True)
- .Move 24, iTop + 6, 42, 18
- .Caption = arr(i, 1)
- .Font.Size = 12
- End With
- With Me.Controls.Add("Forms.TextBox.1", "TextBox" & i, True)
- .Move 60, iTop, 102, 24
- .Text = arr(i, 2)
- .Font.Size = 12
- End With
- Next
- Rem 如果条目多,就启用滚动条
- If iTop + iHeight > Me.Height Then
- Me.ScrollBars = fmScrollBarsVertical
- Me.ScrollHeight = iTop + iHeight
- End If
- End Sub
复制代码 |
|