+ Reply to Thread
Results 1 to 2 of 2

Creating UserForm Controls dynamically

  1. #1
    Registered User
    Join Date
    01-20-2004
    Location
    Western NY
    Posts
    99

    Creating UserForm Controls dynamically

    I wish to create a number of userform controls programatically and then operate on them as the control type they are. I can create the controls and can manipulate the control properties, for example

    Dim ThisCntl as Control
    Dim CntlName as String

    Set ThisCntl = frmABC.Add("Forms.TextBox.1", Name:=CntlName)
    ThisCntl.someCntlprop = somevalue

    However, how to I operate on this recently created Control/TextBox so that I can manipulate the TextBox properties

    Any help would be appreciated.

    Thanks.

  2. #2
    Registered User
    Join Date
    01-20-2004
    Location
    Western NY
    Posts
    99
    Well, I figured out the answer myself. You can use any appropriate property for the control. Thus if a control is a TextBox, all TextBox properties are valid to set or interrogate (even though the VBA editor does not automatically display those selections during code build). In my original example, "someCntlProp" can be any property, method, etc., that is valid for a TextBox.

    Dim ThisCntl as Control
    Dim CntlName as String

    Set ThisCntl = frmABC.Add("Forms.TextBox.1", Name:=CntlName)
    ThisCntl.someCntlprop = somevalue

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1