how can i make a string i added to a label to go 2 the next line instead of adding it like it keeps moving to the right
Printable View
how can i make a string i added to a label to go 2 the next line instead of adding it like it keeps moving to the right
You can use vbCrLf (Carriage Return/Line Feed), ie:
vb Code:
Label1.Caption = "Line 1" & vbCrLf & "Line 2" & vbCrLf & "Line 3"
It also works the same with textboxes, but you *need* to turn multiline on with a textbox otherwise the vbCrLf is just an ugly black box :-)
that might work but theres gonna be a lot of lines and it has a input so on every input it needs to go to a new line
If there's going to be a lot of lines, use a textbox with a scrollbar (you need to turn those on in properties too :-))
If you're going to have a SERIOUS amount of lines, you'll need to use a *rich* textbox (RTB or RichTextBox) which can handle more than 64k of data (unlike a normal textbox, which is limited)
the "Line 1" didnt work either
im using Microsoft Visual Basic 2005 Express
instead of .caption it has .text
ure in wrong section..Quote:
Originally Posted by CemeteryRidge
and if it has .text it isn't a label, it's a textbox.
But yeah, as omfgz says, you need to post in the VB.NET section, we only deal with classic VB, which is VB6 and below for the most part
Fixing the height of the label is as simple as:
vb Code:
Private Sub Command1_Click() Label1.Caption = Label1.Caption & vbCrLf & "Test" Label1.Height = TextHeight(Label1.Caption) + 40 End Sub
VB.NET has an 'upgrade' feature to take a VB6 project and convert it to .NET. While there's usually errors, for something as simple as this I'm sure it will convert it correctly.
I attached the VB6 project. Unzip it and open the .vbp file with VB.NET.