CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2000
    Location
    Houston, Tx, USA.
    Posts
    25

    Instantiating Intrinsic controls

    Hi,
    In my program I have two screens. Screen1 has input box which accepts a numberic value. Screen2 has to display the text boxes based on the input given in the Screen1. For example, if user inputs five in the input box of Screen1, the Screen2 should display five text boxes.

    Thanks in advance,
    Vamsi


  2. #2
    Join Date
    Apr 2000
    Location
    South Carolina,USA
    Posts
    2,210

    Re: Instantiating Intrinsic controls

    Here is a sample of creating controls at run time.
    Start a new project, Paste this code into the General declarations section of the form. Run it.
    You will see a clickable button on the form

    option Explicit

    ' Declare object variable as CommandButton.
    private withevents cmdObject as CommandButton

    private Sub Form_Load()
    set cmdObject = frmCreate.Controls.Add("VB.CommandButton", "cmdOne")
    cmdObject.Visible = true
    cmdObject.Caption = "Dynamic Command Button"
    cmdObject.Move 1000, 1000, 1000, 1000
    End Sub

    private Sub cmdObject_Click()
    print "This is a dynamically added control"
    End Sub

    private Sub Form_Unload(Cancel as Integer)
    ' get rid of created control
    me.Controls.Remove cmdObject

    End Sub




    John G

  3. #3
    Join Date
    Jun 2000
    Location
    Houston, Tx, USA.
    Posts
    25

    Re: Instantiating Intrinsic controls

    Hi John,
    Thanks alot for information.

    Thanks,
    Vamsi


Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured