Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: JpGames on Wed 11/04/2007 19:27:07

Title: 2 variables in the same string
Post by: JpGames on Wed 11/04/2007 19:27:07
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
Title: Re: 2 variables in the same string
Post by: Scorpiorus on Wed 11/04/2007 19:33:58
That's how you can do it:

lblvitalidad.Text = String.Format( "%d / %d", vitalidad, maxvitalidad );
Title: Re: 2 variables in the same string (solved)
Post by: JpGames on Wed 11/04/2007 20:22:15
Thank you very much. It works perfect  ;D