|
-
Mar 10th, 2011, 03:34 PM
#1
Thread Starter
Junior Member
Multiline Label help
Hey guys, I have a problem that I cant seem to figure out. I have a multiline label that im trying to add a line everytime I click the button. Its basically adding a new CD track name, CD minutes, and CD seconds to each new line for everytime the user inputs the given information:
1 Track_Name1 3 min. 13 sec.
2 Track_Name2 2 min. 34 sec.
3 Track_Name3 3 min. 01 sec.
.
.
.
But it keeps adding the "new" line in the position of the old one, so its only displaying on 1 line. I tried using a vbCrLf, but I might have it in the wrong spot?
heres what I got...
Code:
Private Sub btnAddCut_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddCut.Click
cutCounter += 1
lblPlayList.Text = CStr(cutCounter) & " " & txtTitle.Text & " " & txtCutMin.Text & " min. " & txtCutSec.Text & " sec." & vbCrLf
txtCutMin.Clear()
txtCutSec.Clear()
txtTitle.Clear()
End Sub
The cutCounter is obviously the track number, and it clears the current info for the new information. Thanks for any help...
-
Mar 10th, 2011, 03:37 PM
#2
Re: Multiline Label help
This part:
lblPlayList.Text =
means that you will be replacing what is there with the new string. That's not what you want. Replace it with this:
lblPlayList.Text &=
That will take what is there and concatenate on the new part.
My usual boring signature: Nothing
 
-
Mar 10th, 2011, 04:56 PM
#3
Re: Multiline Label help
Or if you want to make your code a little easier to understand you could use: -
lblPlayList.Text = lblPlayList.Text + "Whatever"
Of course this will be considered 'Old hat' by some of the purists.
Poppa.
Along with the sunshine there has to be a little rain sometime.
-
Mar 10th, 2011, 05:01 PM
#4
Re: Multiline Label help
The only problem I have with that is the use of + rather than &. They do the same thing, and there is technically nothing wrong with that, especially if you have Option Strict ON, but if you don't have Option Strict ON, there are times when + doesn't do what you expect it to do when working with strings that could be interpreted as numbers. Therefore, I much prefer the use of & for string concatenation since there can be no ambiguity about it.
My usual boring signature: Nothing
 
-
Mar 10th, 2011, 07:24 PM
#5
Hyperactive Member
Re: Multiline Label help
Is
Code:
lblPlayList.Text = lblPlayList.Text & (whatever) & vbnewline
not sufficient??
-
Mar 10th, 2011, 07:37 PM
#6
Re: Multiline Label help
Yes, it is entirely sufficient.
My usual boring signature: Nothing
 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|