Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to create textbox and label controls dynamically?

Posted on 2007-03-19
1
Medium Priority
?
214 Views
Last Modified: 2010-04-23
I am trying to find a way to create label and textbox controls dynamically when a user hits a button through code.

LabelValue1: [TextBox1]
LabelValue2: [TextBox2]

The following code is giving me an error after the Dim statement.

Error: Variable ‘NewLabel; is used before it has been assigned a value.  A null reference exception could result at runtime.

            Dim NewLabel As Label
            NewLabel.Height = 19
            NewLabel.Width = 25
            NewLabel.Text = "Nothing"
            NewLabel.Location = New System.Drawing.Point(13, 13)

            Me.Controls.Add(NewLabel)

What am I missing?
0
Comment
Question by:endrec
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 6

Accepted Solution

by:
kerryw60 earned 2000 total points
ID: 18751331
Dim NewLabel As New Label
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question