[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 195
  • Last Modified:

Decimal to String

HI There,

I am trying to convert a value of type Decimal into String without loosing any value after the decimal point.

i.e: Private amount as Decimal = 265.10

If I use cStr(amount), the value is becoming 265.1

How to keep data (265.10)?

Thanks.
0
theartha
Asked:
theartha
  • 2
  • 2
1 Solution
 
Éric MoreauSenior .Net ConsultantCommented:
have you tried:
dim x as string
x = amount.tostring("#,##0.00")
0
 
Éric MoreauSenior .Net ConsultantCommented:
The reason is that a Decimal value (like any other numeric type) does not keep in memory worth less 0-value.
0
 
thearthaAuthor Commented:
@emoreau:

I tried ToString("N2", System.Globalization.CultureInfo.CreateSpecificCulture("en-US"))
 but if the amount is more, its getting formatted.

It should be 265265.10 not 265,265.10

Thanks.
0
 
thearthaAuthor Commented:
I used ToString(###0.00), it works. Thanks
0

Featured Post

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now