Guest Danno Posted October 21, 2002 Posted October 21, 2002 I have a string and variable that I am trying to get added into a ListBox and trying to format it to no avail. Here is a sample.. totalCost = ((Convert.ToInt32(txtYears.Text) * 12) - 1) * payment lstDisplay.Items.Add(String.Format("{0,7}", "Total amount paid over " & txtYears.Text & " years: " & FormatCurrency(totalCost))) and although it puts the concantenated string into the listbox, no matter what I do the string will not format (stays on the left border). Any Suggestions? Quote
Guest Danno Posted October 21, 2002 Posted October 21, 2002 I need to modify the post. The actual code was: lstDisplay.Items.Add([b]String.Format[/b]("{0,7}", "Total amount paid over " &_ txtYears.Text & " years: " & FormatCurrency(totalCost))) I did a carriage return on this with the "_" so that it won't scroll off the page... Quote
*Gurus* Derek Stone Posted October 21, 2002 *Gurus* Posted October 21, 2002 Try the following. String.Format("Total amount paid over " & txtYears.Text & " years: {0,7}", FormatCurrency(totalCost)) Quote Posting Guidelines
Guest Danno Posted October 21, 2002 Posted October 21, 2002 I will try it this evening....the end result string should say something like: Total amount paid over 14 years: $250,000 Will your solution do that? Is it the string, followed by the formatting, a comma and then the other variable? Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.