Reputation: 57
So what I've done is manually insert space between the variables. Although it works, but if the variables is a bit long, it would move to the right. Here are the coding that I've done.
lstOutput.Items.Add("Items Quantity Prices")
lstOutput.Items.Add("Pizza Slices " & quanPizza & " " & FormatCurrency(pricePizza, 2))
lstOutput.Items.Add("Fries " & quanFries & " " & FormatCurrency(priceFries, 2))
lstOutput.Items.Add("Soft Drinks " & quanSoftDrinks & " " & FormatCurrency(priceSoftDrinks, 2))
lstOutput.Items.Add("")
lstOutput.Items.Add("Total " & FormatCurrency(totalPrice, 2))
Here is when the variable is a bit long.
How can i make it stay as if it is in a column?
Upvotes: 1
Views: 107
Reputation: 5453
You can use Padding to format your strings as expected. Use this like below :
lstOutput.Items.Add("Items".PadRight(30) & "Quantity".PadRight(30) & "Prices".PadRight(30))
lstOutput.Items.Add("Pizza Slices".PadRight(30) & quanPizza.PadRight(30) & FormatCurrency(pricePizza, 2).ToString().PadRight(30))
Here is an Example for you.
Upvotes: 2