MSDN Archive Home
Help and FAQs
All Resource Updates
Change History (all pages)
This is a basic calculator that covers all the simple features of Microsoft Standard calculator like digit grouping etc...
very much helpful for starters...
Oct 10 2007 at 5:02 PM
, version 1
Apr 15 2009 at 12:38 PM
In Calculator.vb, line 180:
If Str(0) < 4 Then
should be replaced by:
If Str(0).Length < 4 Then
The problem exhibits clearly on a French computer, because with the existing code, VB.NET tries to automatically cast Str(0) to a double; and this fails, because, the group separator character used by the sample (,) is in fact a decimal separator with a French culture...
Also linked to a culture problem is:
should be replaced by
Last thing, (but I didn't investigate much) due to a culture problem,
is when validating a number (by applying an operator for example), a decimal number "1.234" is transformed into "1,234." though I didn't check "Digit Grouping"...
I understand, making the sample suitable for all cultures will add complexity; so an easier solution is to force the american culture:
I added this at the end of the main form's constructor:
Hope this helps
Jun 26 2009 at 1:16 AM
This is why VB developers get such a bad name.
If you intend to improve this sample you may start by looking at stack-based operations, as well as letting the framework do things its better at doing than you are.. like digit grouping.
Apr 10 2012 at 1:26 PM
You Could Use Val(1.234) to use user's defined decimal character. Val() converts automatically the characters according to system configuration of the user
Sign in to add a comment
Wed Oct 10 2007 at 5:02 PM
More Tags ...
Visual Studio 2005
Visual Studio 2008
Visual Studio 2010
Manage Your Profile
MSDN Flash Newsletter
© 2008 Microsoft Corporation. All rights reserved.