开发者

The name of a frame in a loop

I want to add a Control in every for in my application. Let's say I have 5 frames... I want to do someting like this:

Set cControl = Me!iooly&i.Controls.Add("Forms.Label.1", "str12" & i, True)
    With cControl
        .Caption = "1/2"
        .Width = 20
        .Height = 8
        .Top = 10
        .Left = 435
    End With

i is a counting 开发者_如何学编程variable the problems is that Me!iooly&i ... Can I do this operation when my frames have names la iooly1, iooly2, iooly3 and so on?


Your Me is presumably a form? This won’t work. Also, the Me!iooly&i syntax doesn’t work, this only works if your string is a constant.

You can use the Forms collection though:

Set cControl = Forms("iooly" & i).Controls.Add(…)

This is assuming that the form already exists. If it doesn’t, you need to first load it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜