Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Label vs. TextBox for displaying data on userform

Status
Not open for further replies.

mintjulep

Technical User
Aug 20, 2004
1,551
JP
Follow-on from thread707-1481982 where fumei suggests the use of a label.

It's obvious that labels are perfectly fine for the display of data where there is no need for user interaction with the value.

I will admit that I am guilty of using textboxes for display-only data - usually with .active = false to prevent the user from attempting to interact with the data.

So, beyond the philosophical and aesthetic issues, is there an actual (detectable, measurable) performance penalty associated with using textboxes instead of labels?
 
If you have great gobs of them there may be but it would likely be detectable only in a benchmark test ... for example, populate the screen 10,000 times using textboxes in one case and labels in another.

For most practical purposes, I would not expect a detectable difference for the user.
 
I would agree. Performance issues would be detectable only if you worked hard at finding one.

It is a matter of best practices.

Use controls for what they are designed for.

Labels are designed to display text.
Textboxes are designed to get user input of text.

If you are displaying text, that is, there is no user input...use a label.

If you are trying to get user input, use a textbox.

As another example, Textbox1.Value and Textbox1.Text will be the same thing. If "yadda" is in the the textbox, the .Value and .Text will return "yadda".

However, best practices would state that generally it is better to be explicit.

If you want to use the contents of the textbox as a string - which you do - then think of it as a string, get it as a string. As.......Text.

Why? Because getting into the habit of using .Value can possibly return unexpected results. Some controls have a .Value that may not be what you actually want.

Use .Value when you mean .Value.

Use .Text when you mean .Text.

Use a label when you mean to display text.

Use a textbox when you mean to GET text.

But performance...nah.

faq219-2884

Gerry
My paintings and sculpture
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top