Variables in Labels?

Started by MorpheusKitami, Sat 07/12/2019 00:56:54

Previous topic - Next topic

MorpheusKitami

So, instead of doing text like a normal person through the standard format, I'm instead using a Label on the GUI to display text. This has so far not caused me any trouble. However when I try adding a variable to it, it gives me a parse error. Am I doing something wrong or is this just not possible?

Code: ags

Label1.Text = ("Its a 44-70 Hans & Rogers pump-action rifle. It has %d rounds left.", rifle_ammo);

Crimson Wizard

Use String.Format, it creates a formatted string which you can assign anywhere.

Code: ags

Label1.Text = String.Format("Its a 44-70 Hans & Rogers pump-action rifle. It has %d rounds left.", rifle_ammo);

MorpheusKitami

Thanks, I apologize for asking such a simple question but searching provided me with no obvious results.

SMF spam blocked by CleanTalk