Solved

How to create textbox and label controls dynamically?

Posted on 2007-03-19
1
201 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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
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…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

708 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now