VB中控件排列不方便?
VB6.0如何利用循环i来排列frame里面的label等控件?
1,不自带findcontrol函数?
2,或者如何直接将“label”+i.tostring()字符串转化成控件?
3,或者其他的命令。
Private Sub Command1_Click()
For i = 0 To 10
Dim lab As Label
Set lab = Me.Controls.Add("vb.label", "label" & i)
With lab
.Caption = "label" & i
.Top = i * (.Height + 10)
.Visible = True
End With
Next i
Set conl = findControl("Command1")
conl.Caption = "OK"
Set conl = findControl("label5")
conl.Caption = "12345"
End Sub
Function findControl(name As String) As Control
For Each i In Me.Controls
If i.name = name Then
Set findControl = i
Exit Function
End If
Next
End Function