Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Stephens' C# Programming with Visual Studio 2010 24-Hour Trainer
This is the forum to discuss the Wrox book Stephens' C# Programming with Visual Studio 2010 24-Hour Trainer by Rod Stephens; ISBN: 9780470596906
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Stephens' C# Programming with Visual Studio 2010 24-Hour Trainer section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 26th, 2011, 02:47 AM
Registered User
Points: 42, Level: 1
Points: 42, Level: 1 Points: 42, Level: 1 Points: 42, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2011
Posts: 9
Thanks: 5
Thanked 0 Times in 0 Posts
Cool Try it No 11

Howdy I have your book Its great
Im stuck on the try it in chapter 11
I have C#2010 express running on win7 64Bit

I have set the page out in the same fashion as your example

The name properties I gave the NumericUpDown are quantity1 quantity2 and so on
when i go into the calculate button to put in the input values

[decimal quantity1 = quantity1NumericUpDown.Value]

I get the error
The name 'quantity1NumericUpDown' does not exist in the current context

Any suggestions on where im might be going wrong

I am sure I have named everything right and calling it as I have named it
  #2 (permalink)  
Old April 26th, 2011, 07:05 AM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Quote:
The name properties I gave the NumericUpDown are quantity1 quantity2 and so on
Shouldn't you be using those properties in the code then?

decimal quantity1 = quantity1.Value

Since you now declare quantity1 twice, you need to rename either one of them. E.g.:

decimal quantity = quantity1.Value

or

decimal quantity1 = quantity1NumericUpDown.Value
In the latter case, you should rename the control from quantity1 to quantity1NumericUpDown.

Hope this helps,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
The Following User Says Thank You to Imar For This Useful Post:
harold4964 (April 29th, 2011)
  #3 (permalink)  
Old April 26th, 2011, 09:02 AM
Rod Stephens's Avatar
Wrox Author
Points: 3,166, Level: 23
Points: 3,166, Level: 23 Points: 3,166, Level: 23 Points: 3,166, Level: 23
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2006
Location: , , .
Posts: 647
Thanks: 2
Thanked 96 Times in 95 Posts
Default

It sounds like Imar may be right. Make sure the name you use for the control is the same in the code and in the form designer. It sounds like the designer think you didn't name them quantity1NumericUpDown etc. but possibly something like quantity1.
__________________
Rod

Rod Stephens, Microsoft MVP

Essential Algorithms: A Practical Approach to Computer Algorithms

(Please post reviews at Amazon or wherever you shop!)
The Following User Says Thank You to Rod Stephens For This Useful Post:
harold4964 (April 29th, 2011)
  #4 (permalink)  
Old April 29th, 2011, 09:17 PM
Registered User
Points: 42, Level: 1
Points: 42, Level: 1 Points: 42, Level: 1 Points: 42, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2011
Posts: 9
Thanks: 5
Thanked 0 Times in 0 Posts
Default Thanks guys

Not sure how i missed that one
I think I was trying to Over Complicate the problem
just goes to show that It can be so simple and still under your nose

anyways I got another question
In the Try it no 11 where i am trying to display my results

[extPrice1TextBox1.text = extPrice1.ToString("C");]

I am getting an error telling me

Error 1 'decimal' does not contain a definition for 'Text' and no extension method 'Text' accepting a first argument of type 'decimal' could be found (are you missing a using directive or an assembly reference?)

everything before this built ok but when i start the code for the display results comes up with this error

im using VisualC# 2010 Express on Win7 64Bit
  #5 (permalink)  
Old April 30th, 2011, 07:41 PM
Rod Stephens's Avatar
Wrox Author
Points: 3,166, Level: 23
Points: 3,166, Level: 23 Points: 3,166, Level: 23 Points: 3,166, Level: 23
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2006
Location: , , .
Posts: 647
Thanks: 2
Thanked 96 Times in 95 Posts
Default

[extPrice1TextBox1.text = extPrice1.ToString("C");]

The error message sounds like it thinks the variable extPrice1TextBox1 is a decimal variable and not a text box. Then it complains because the decimal data type doesn't have a Text property or method.

Double check that this is where the error is and that extPrice1TextBox1 is a text box and not a misnamed variable. If you're not sure, right-click on the variable and select "Go To Definition" to see where it's defined. (If it throws you into the code containing the form definitions, just take a look and close it.)

Let me know if that solves it.
__________________
Rod

Rod Stephens, Microsoft MVP

Essential Algorithms: A Practical Approach to Computer Algorithms

(Please post reviews at Amazon or wherever you shop!)
  #6 (permalink)  
Old March 26th, 2012, 09:58 AM
Registered User
Points: 15, Level: 1
Points: 15, Level: 1 Points: 15, Level: 1 Points: 15, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2012
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Trying to make Try-IT in 11 Chapter.
But had a message "System.FormatException was unhandled" at this line:
decimal priceEach1 = decimal.Parse(priceEach1TextBox.Text);
Any ideas what should I correct?
  #7 (permalink)  
Old March 26th, 2012, 02:43 PM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Hi there,

I don't have the book so I don't exactly what the example is supposed to do, but could it be that your copy of Windows has other regional settings (e.g. another language than English, or just changed regional settings0. If that's the case, you may need to swap commas and dots. E.g. use 323,35 instead of 323.35.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
  #8 (permalink)  
Old March 29th, 2012, 10:55 AM
Registered User
Points: 15, Level: 1
Points: 15, Level: 1 Points: 15, Level: 1 Points: 15, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2012
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you, Imar. It really helps.
  #9 (permalink)  
Old March 30th, 2012, 08:49 AM
Rod Stephens's Avatar
Wrox Author
Points: 3,166, Level: 23
Points: 3,166, Level: 23 Points: 3,166, Level: 23 Points: 3,166, Level: 23
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2006
Location: , , .
Posts: 647
Thanks: 2
Thanked 96 Times in 95 Posts
Default

Sorry for the slow reply. I'm out of town and logging in is iffy.

Switching the . and , will do it if your system is set up that way. You would get that message in any case where the text doesn't look like a number. For example, if you enter "1.2.3" or "two" or if you leave the field blank.

In later lessons you'll learn how to test for bad values and how to use the try catch block to protect the program in case the user enters something unexpected like this.
__________________
Rod

Rod Stephens, Microsoft MVP

Essential Algorithms: A Practical Approach to Computer Algorithms

(Please post reviews at Amazon or wherever you shop!)
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Previewing VideoRecording Not working Listings 11-9 to 11-10 rinkle BOOK: Professional Android 2 Application Development 1 June 21st, 2010 01:03 PM
Problem Playing Video using listings 11-4 through 11-6 emanuel BOOK: Professional Android 2 Application Development 3 April 7th, 2010 02:16 PM
Chapter 11 icculus1 BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 1 July 30th, 2009 05:15 PM
Chapter-11 Carlw BOOK: Professional SharePoint 2007 Development ISBN: 978-0-470-11756-9 0 October 16th, 2008 02:08 PM
chapter 11 figure 11-7 relative positioning pelopito BOOK: Beginning CSS: Cascading Style Sheets for Web Design ISBN: 978-0-7645-7642-3 2 November 29th, 2007 06:11 AM



All times are GMT -4. The time now is 02:56 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.