views:

138

answers:

3

In visual basic , when you create a label in form view (via click and drag) is it possible to make the label have both a string and a variable included in it?

*

turns=1
label1.text = ("Turn:"(turns))

*

for example , so that label 1 will display

*Turn 1*
A: 

label1.text = "Turn: " & turns.ToString()

madcolor
is that the code for it? Or are you saying that it is too stringy?
Jimbo8098
Try it. I believe it should work. The ToString() is used to convert "turns" to a string value.
madcolor
A: 

Are you talking VB.Net, or something else?

In .Net:

turns = 1
Label1.Text = String.Format("Turn {0}", turns)
Joel Coehoorn
How can you tell which is which? I have the visual basic express edition from microsoft. I am using the windows forms application utility.
Jimbo8098
+1  A: 

Every control has the Tag property which can store any object reference. However, you can't easily give a label a sort of "format string" and then make it update whenever you change a variable, if that's what you were thinking of.

If you were just talking about formatting the label to use a variable's value in the text, then you can't do that within the designer - you'll have to do it somewhere in the code (e.g. in the constructor, after the designer code has been called).

Jon Skeet
I thought so. wasn't sure. Thanks
Jimbo8098