Correct space and add $ sign

The code below produces the form shown here >> http://screencast.com/t/w0CP7X9kE6 after the Calculate Revenue button is pressed.  I like how the information is being displayed with a couple of exceptions.  I'd like to add a $ sign in the Total Revenue Generated area and add a space between the $ sign and the amount for each item above it.  I need to know how to change the attached code and on what line to make the change.  Assistance is greatly appreciated.

/* 304_PennerT_Lab03
Ted R Penner
000305507
Self-Paced, Per prior discussion with instuctor.
Oct 12, 2011
Purpose: To calculate revenue from stadium ticket sales.*/

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace _304_PennerT_Lab03
{
    public partial class stadiumSeatingForm : Form
    {
        public stadiumSeatingForm()
        {
            InitializeComponent();
        }
        private void calculateRevenueButton_Click_1(object sender, EventArgs e)
        {
            try
            {
                // Declare Named Constants

                    const decimal CLASS_A_SEATS = 15.00m; const decimal CLASS_B_SEATS = 12.00m; const decimal CLASS_C_SEATS = 9.00m;

                // Declare Varialbles

                    decimal classATickets; decimal classBTickets; decimal classCTickets;
                    decimal classARevenue; decimal classBRevenue; decimal classCRevenue;
                    decimal totalRevenue;

                // Convert Text Box Values (which are string values) to the appropriate data type using a Parse method and assign to related variable.

                classATickets = decimal.Parse(classATicketsSalesBox.Text); classBTickets = decimal.Parse(classBTicketsSalesBox.Text); classCTickets = decimal.Parse(classCTicketsSalesBox.Text);

                // Process Calculations

                    classARevenue = classATickets * CLASS_A_SEATS; classBRevenue = classBTickets * CLASS_B_SEATS; classCRevenue = classCTickets * CLASS_C_SEATS;
                    totalRevenue = classARevenue + classBRevenue + classCRevenue;

                // Display Numeric Output to appropriate control by converting the numeric value to a string using the ToString method.

                    classARevenueBox.Text = classARevenue.ToString("c"); classBRevenueBox.Text = classBRevenue.ToString("c"); classCRevenueBox.Text = classCRevenue.ToString("c");
                    totalRevenueBox.Text = totalRevenue.ToString();
            }
            catch (Exception ex)
            {
                // Display the deault error message.
                
                    MessageBox.Show(ex.Message);
            }
        }
        private void clearButton_Click(object sender, EventArgs e)
        {
            // Clear form and set focus
               
                classATicketsSalesBox.Text = " "; classBTicketsSalesBox.Text = " "; classCTicketsSalesBox.Text = " ";
                classARevenueBox.Text = " "; classBRevenueBox.Text = " "; classCRevenueBox.Text = " ";
                totalRevenueBox.Text = " ";
        }
        private void exitButton_Click(object sender, EventArgs e)
        {
            // Close application
                
                this.Close();
        }
    }
}

Open in new window

rtod2Asked:
Who is Participating?
 
KBergerCommented:
Hi,

You could try ToString("$ 0.000,00") or any Otter Format-String. Try Reading about formatting Numeros values with ToString

Cheers,

Kristof
0
 
johnsoneSenior Oracle DBACommented:
Couldn't you change this:

totalRevenueBox.Text = totalRevenue.ToString();

to this:

totalRevenueBox.Text = "$ " + totalRevenue.ToString();
0
 
KBergerCommented:
Hi,

Wouldn't totalRevenue.Text=totalRevenue.ToString("c") do the Trick?
This is how all Otter bxes are Vormärzes As well...

Regards,

Kristof
0
 
rtod2Author Commented:
Kberger, nice!

This works but still doesn't give a space prior to the value.
totalRevenueBox.Text = totalRevenue.ToString("c");

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.