I have a table column of SQL smallmoney type which I am updating via a form
input field defined as decimal.
If I enter, say, 51.09 via the decimal input field (representing $51.09),
this is
displayed as 5109.0000 when I view the table data.
I'm not sure why 4 decimal places are being shown, and how would I get the
table data to represent the input i.e. 51.09? I don't want to have to divide
by 10,000
every time I want to display data or do calculations.
Thanks 3 3970
"Paolo" <Pa***@discussi ons.microsoft.c omwrote in message
news:1B******** *************** ***********@mic rosoft.com...
>I have a table column of SQL smallmoney type which I am updating via a form
input field defined as decimal.
If I enter, say, 51.09 via the decimal input field (representing $51.09),
this is
displayed as 5109.0000 when I view the table data.
I'm not sure why 4 decimal places are being shown, and how would I get the
table data to represent the input i.e. 51.09? I don't want to have to
divide
by 10,000
every time I want to display data or do calculations.
Most probably you have fallen into a decimal separator problem. You may
have your client environment set to interpret the comma as a decimal
separator and the dot as a thousands separator, but the data you are keying
in follows the opposite criterion. If you enter "51.09" but the dot is set
to be the thousands separator, you get "5109".
Follow your code carefully, and find out the point at which you are doing
the conversion from text into decimal. Then ensure that you are using the
correct Globalization to match the format in which the numbers are being
entered.
For instance, if you are entering your "51.09" into TextBox1 and you are
converting into decimal like this:
decimal d = decimal.Parse(T extBox1.Text);
Then change it into:
CultureInfo ci = new CultureInfo("en-US");
decimal d = decimal.Parse(T extBox1.Text, ci);
This will always use the period as a decimal separator, regardles of the
CurrentCulture setting.
Alberto: I'm capturing transAmount via a MaskedTextbox whose mask is
$99,999.00 and for which the culture is set to English(Austral ia).
I have also: msktxtbxAmount. ValidatingType = typeof(System.D ecimal);
The code capturing transAmount is:
private void msktxtbxAmount_ TypeValidationC ompleted(object sender,
TypeValidationE ventArgs e)
{
if (!e.IsValidInpu t)
MessageBox.Show ("Invalid amount", "Error",
MessageBoxButto ns.OK);
else
transAmount = (decimal)e.Retu rnValue; <<<<<<<
}
Perhaps I should divide transAmount by 100 (not 10,000!) before I update the
table?
"Alberto Poblacion" wrote:
"Paolo" <Pa***@discussi ons.microsoft.c omwrote in message
news:1B******** *************** ***********@mic rosoft.com...
I have a table column of SQL smallmoney type which I am updating via a form
input field defined as decimal.
If I enter, say, 51.09 via the decimal input field (representing $51.09),
this is
displayed as 5109.0000 when I view the table data.
I'm not sure why 4 decimal places are being shown, and how would I get the
table data to represent the input i.e. 51.09? I don't want to have to
divide
by 10,000
every time I want to display data or do calculations.
Most probably you have fallen into a decimal separator problem. You may
have your client environment set to interpret the comma as a decimal
separator and the dot as a thousands separator, but the data you are keying
in follows the opposite criterion. If you enter "51.09" but the dot is set
to be the thousands separator, you get "5109".
Follow your code carefully, and find out the point at which you are doing
the conversion from text into decimal. Then ensure that you are using the
correct Globalization to match the format in which the numbers are being
entered.
For instance, if you are entering your "51.09" into TextBox1 and you are
converting into decimal like this:
decimal d = decimal.Parse(T extBox1.Text);
Then change it into:
CultureInfo ci = new CultureInfo("en-US");
decimal d = decimal.Parse(T extBox1.Text, ci);
This will always use the period as a decimal separator, regardles of the
CurrentCulture setting.
Yes, division by 100 gives me 51.09 in the table.
"Paolo" wrote:
Alberto: I'm capturing transAmount via a MaskedTextbox whose mask is
$99,999.00 and for which the culture is set to English(Austral ia).
I have also: msktxtbxAmount. ValidatingType = typeof(System.D ecimal);
The code capturing transAmount is:
private void msktxtbxAmount_ TypeValidationC ompleted(object sender,
TypeValidationE ventArgs e)
{
if (!e.IsValidInpu t)
MessageBox.Show ("Invalid amount", "Error",
MessageBoxButto ns.OK);
else
transAmount = (decimal)e.Retu rnValue; <<<<<<<
}
Perhaps I should divide transAmount by 100 (not 10,000!) before I update the
table?
"Alberto Poblacion" wrote:
"Paolo" <Pa***@discussi ons.microsoft.c omwrote in message
news:1B******** *************** ***********@mic rosoft.com...
>I have a table column of SQL smallmoney type which I am updating via a form
input field defined as decimal.
>
If I enter, say, 51.09 via the decimal input field (representing $51.09),
this is
displayed as 5109.0000 when I view the table data.
>
I'm not sure why 4 decimal places are being shown, and how would I get the
table data to represent the input i.e. 51.09? I don't want to have to
divide
by 10,000
every time I want to display data or do calculations.
Most probably you have fallen into a decimal separator problem. You may
have your client environment set to interpret the comma as a decimal
separator and the dot as a thousands separator, but the data you are keying
in follows the opposite criterion. If you enter "51.09" but the dot is set
to be the thousands separator, you get "5109".
Follow your code carefully, and find out the point at which you are doing
the conversion from text into decimal. Then ensure that you are using the
correct Globalization to match the format in which the numbers are being
entered.
For instance, if you are entering your "51.09" into TextBox1 and you are
converting into decimal like this:
decimal d = decimal.Parse(T extBox1.Text);
Then change it into:
CultureInfo ci = new CultureInfo("en-US");
decimal d = decimal.Parse(T extBox1.Text, ci);
This will always use the period as a decimal separator, regardles of the
CurrentCulture setting. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Batista, Facundo |
last post by:
Here I send it.
Suggestions and all kinds of recomendations are more than welcomed.
If it all goes ok, it'll be a PEP when I finish writing/modifying the code.
Thank you.
.. Facundo
|
by: Batista, Facundo |
last post by:
I'm proud to announce that the PEP for Decimal Data Type is now published
under the python.org structure:
http://www.python.org/peps/pep-0327.html
This wouldn't has been possible without the help from Alex Martelli, Aahz,
Tim Peters, David Goodger and c.l.p itself.
After the pre-PEP roundups the features are almost established. There is not
agreement yet on how to create a Decimal from a float, in both explicit and
|
by: John Bentley |
last post by:
John Bentley:
INTRO
The phrase "decimal number" within a programming context is ambiguous. It could
refer to the decimal datatype or the related but separate concept of a generic
decimal number. "Decimal Number" sometimes serves to distinguish Base 10
numbers, eg "15", from Base 2 numbers, Eg "1111". At other times "Decimal
Number" serves to differentiate a number from an integer. For the rest of this
post I shall only use either...
|
by: hana1 |
last post by:
Hello experts,
I used to program in C/C++ and now switched to Java. I am having a
difficulty that I need your help with. How can I limit a double variable to
hold 2 decimal points only? Say I have an array of 50 doubles that each ahs
a number such as 23.9918444. I want to round round this number to 23.99 and
any other calculations done on it should have the same precision.
I know that Decimal Format does the rounding but the thing that...
|
by: Kay Schluehr |
last post by:
I wonder why this expression works:
>>> decimal.Decimal("5.5")**1024
Decimal("1.353299876254915295189966576E+758")
but this one causes an error
5.5**1024
Traceback (most recent call last):
| |
by: dharmdeep |
last post by:
Hi friends,
I need a sample code in C which will convert a Hexadecimal
number into decimal number. I had written a code for that but it was
too long, I need a small code, so request u all to provide me with
small sample code for that.
|
by: jmarr02s |
last post by:
I am trying to change my Amount column Data Type from Integer to
Decimal (precision 9 digits, scale 3, that is 6 digits to the left of
decimal and 3 digits to the right of decimal.
Here is the error message I received SQL0443N Routine "SYSPROC.ALTOBJ"
I sense this is a security issue, something my DBA must resolve and
some aspect I do not have permission to do?
Thanks,
|
by: cmdolcet69 |
last post by:
Public ArrList As New ArrayList
Public bitvalue As Byte()
Public Sub addvalues()
Dim index As Integer
ArrList.Add(100)
ArrList.Add(200)
ArrList.Add(300)
ArrList.Add(400)
ArrList.Add(500)
|
by: FAQ server |
last post by:
-----------------------------------------------------------------------
FAQ Topic - How do I convert a Number into a String with
exactly 2 decimal places?
-----------------------------------------------------------------------
When formatting money for example, to format 6.57634 to
6.58, 6.5 to 6.50, and 6 to 6.00?
Rounding of x.xx5 is uncertain, as such numbers are not
represented exactly. See section 4.7 for Rounding issues.
|
by: Elroy Flynn |
last post by:
Decimal a = 42.485M;
Decimal b = 48M;
Decimal c = a / b;
Console.WriteLine(c.ToString());
gives the result 0.8851041666666666666666666667
The correct, exact answer is .885.
I know that floating point types cannot represent some values
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |