Library tutorials & articles
Label Control
Setting the text
As the label control is generally used as a label (!), you will probably know what text to use at design time, and will use the property window. However, to set the text in a label at runtime you use the following syntax:
Label1.Caption = Text
where Text is a string counting the text to be used. The code below sets Label1's text to Hello!
Label1.Caption = "Hello"
If you want to have more than one line of text in a label you have to set the text at runtime. Because labels uses a carriage return (Chr(10) + Chr(13)) you need to use vbCrLf as the return text, instead of Chr(vbKeyReturn) as you might think. The following example will put the text
An error occured
Please try again
into Label1.
Label1.Caption = "An Error occured" & vbCrLf
& "Please try again"
Related articles
Related discussion
-
VB6 Runtime error 381 subsript out of range Error
by Uncle (2 replies)
-
passing and reading parameters from using Shell
by jigartoliya (0 replies)
-
Convert C++ code to VB6
by mawcot (4 replies)
-
listbox scrollbar
by Dennijr (10 replies)
-
Can you describe Above simple VB6 code?
by pramodmca09 (0 replies)
Related podcasts
-
Christian Beauclair
14 mai 2008 (�mission #0074) ::.Christian Beauclair: Stratégies de migration VB6 vers .NET Nous discutons avec Christian Beauclair des stratégies de migration VB6 vers .NET. Entre autres, nous discutons comment utiliser le "VB 6 Code Advisor" et le "Interop Forms Toolkit" pour ajouter la puiss...
This thread is for discussions of Label Control.