2 variables in the same string

Started by JpGames, Wed 11/04/2007 19:27:07

Previous topic - Next topic

JpGames

I have 2 variables

vitalidad & maxvitalidad

I want show both in the same label (called lblvitalidad) that they looks like

xxx / xxx

lblvitalidad.Text = String.Format("%d", vitalidad," / %d",maxvitalidad);

But it just show the first variable (vitalidad).

I take the example from the users guide =

You can display as many variables as you like in one line:
Display("Life is %d, 2 x Pi = %f, and my dinner is %s.", life, twoPi, "awful");

and replace it with my own variables

lblvitalidad.Text = String.Format("%d, vitalidad, / %d.", maxvitalidad);

but it shows the second variable (maxvitalidad)

What im doing wrong now?  ::)

JpGames

Scorpiorus

That's how you can do it:

lblvitalidad.Text = String.Format( "%d / %d", vitalidad, maxvitalidad );

JpGames

Thank you very much. It works perfect  ;D

SMF spam blocked by CleanTalk