If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Hybrid View

Beginner C# Program Help Please :)

Writing a pretty simple cost calculator, and everything is coming out right except the total of everything. Why is the total for everything displaying placeholders instead of numbers, and how can I fix it? I really appreciate any input, thanks!

Re: Beginner C# Program Help Please :)

Thanks for the reply Arjay. I thought I had taken a shot of the output after debugging. I am just selecting "debug" and then "start debugging." This is what happens when I debug(no errors). I input 1 for each field.

Re: Beginner C# Program Help Please :)

[I think I know what is the problem, but since I started to explain how to debug, I'm going to continue]

What debugging allows you to do is to watch the program variables while your program executes. It also allows you to step through each line of code and makes sure variables are getting set as you expect and other logic is working as intended.

So starting by pressing F5 (debug program) is a good start, but to be really useful, you'll need to set one or more breakpoint so the program will stop so you can inspect the variables.

To do this, set a breakpoint at the following line inside the calculaterevenue...click handler:

Code:

classbtickets = decimal.Parse(classbTextBoxrm.Text);

Just put the mouse over the line above, click and then press F9. You'll notice a little circle appears to the left of the line of code.
Next, press F5 to start debugging. Enter the values and click the calculate button.

You'll notice the program will stop on the break point. To inspect a variable, hold the mouse over the classatickets variable. You should see that the value is the same as what you entered. Next, hold the mouse over the classbtickets variable. You should see either null or "" as the value. This is because this line of code hasn't executed yet.

Press F10 to execute the next line of code to inspect more variables or press F5 to continue running the program (and hit additional breakpoints if any).

Okay, so that's a quick debugging primer, now onto your problem.

I suspect the problem is the style of the Totals text box has been set to Password = true. To check this, open the forms editor, right click on the totals text box and choose properties. Then make sure that the Password entry is set to false.

* The Perfect Platform for Game Developers: Android
Developing rich, high performance Android games from the ground up is a daunting task. Intel has provided Android developers with a number of tools that can be leveraged by Android game developers.

* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.