TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Jes Sie
706
1.2k
277.8k
converting to decimal
Oct 9 2017 12:03 AM
I need assistance again ;( . I have this code snippet below which converts the textbox to a decimal:
private
void
ComputeTotalPremium()
{
try
{
int
persons = Convert.ToInt32(txtTravellingPersons.Text);
decimal
premium = Convert.ToDecimal(lblPremium.Text);
decimal
Total;
Total = persons * premium;
txtTotalPremium.Text = Total.ToString(
"N2"
, CultureInfo.InvariantCulture);
}
catch
(Exception ex)
{
if
(ex
is
FormatException)
{
}
else
{
throw
ex;
}
}
}
The value of txtTravellingPersons.Text is 1.
The original value of lblPremium.Text is 16.00, but when the value was converted to decimal (decimal premium) the 16.00 becomes 1600.
Please note that this piece of code was working ever since I'm using it but now it failed. Thanks for any assistance.
Reply
Answers (
13
)
Text Message Code for access validation
How to generate excel using mvc with css and jquery