Solved

How to create textbox and label controls dynamically?

Posted on 2007-03-19
1
208 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
1 Comment
 
LVL 6

Accepted Solution

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

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Calling web service and its methods dynamically 2 59
SQL syntax in VB.net 5 39
VB.Net Report Printing Issue 3 34
get row value in vb.net 4 14
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…
Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

777 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