Solved

How to create textbox and label controls dynamically?

Posted on 2007-03-19
1
212 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 500 total points
ID: 18751331
Dim NewLabel As New Label
0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Suggested Solutions

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

738 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