Create a textbox from a variable


This is not correct, but how can create a textbox for ex. from a variable, somethig like:

            Dim xx As String
            Dim xx As New TextBox()

best regards
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Fernando SotoRetiredCommented:
Hi rflorencio;

This is not possible to do. What do you need to do that needs this type of requirement?
Not sure I understood correctly, but probably
Dim s = "Hello World!"
Dim x As New TextBox With {.Text = s, .Visible = True, .Location = New Point(20, 20), .Width = 200}

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rflorencioAuthor Commented:

I have some "parameters", like startdate, enddate, prductid for ex. to generate reports. But sometimes i only need for ex. startdate and enddate, others only productid, others all them. I alread done a code to generate controls in runtime mode. But my goal is read the "parameter" for ex. startdate and create a textbox control called startdate to get date, etc ...

best regards
rflorencioAuthor Commented:
I get it.
Jacques Bourgeois (James Burger)PresidentCommented:
You usually create controls dynamically when you do not know beforehand how many controls you coudl need. As an example, if I have a form that has buttons to print reports, and I cannot know when I build application how many reports will be available. This could be done with the technique described by Ark.

In your case however, you know how many controls you might need. In such a situation, it is usually better to create your form as you would, with all the possible controls, but set the the Visible or Enabled property of those that might not be needed to False. The controls are in the form, but the user sees them as inactive (Enabled) or does not see them (Visible).

When, when you need to display information in these controls, simply reset the property to True so that it is activated or visible.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.