Go Premium for a chance to win a PS4. Enter to Win

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

Round a string to two digits

Hello,

How can I round a number to 2 digits

Cheers
0
RIAS
Asked:
RIAS
  • 6
  • 5
2 Solutions
 
Pawan KumarDatabase ExpertCommented:
Sample example pls?
0
 
RIASAuthor Commented:
500.999
400.789
0
 
Pawan KumarDatabase ExpertCommented:
Output should be below correct ?

501.00
400.80
0
Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

 
RIASAuthor Commented:
400.789 to 400.79
0
 
Pawan KumarDatabase ExpertCommented:
Try

Dim a As Decimal
        a = 400.789

        Dim b As Decimal
        b = Math.Round(a, 2)

        Console.WriteLine(b)

Open in new window

0
 
RIASAuthor Commented:
maths.round is giving sqiggly red line
0
 
Pawan KumarDatabase ExpertCommented:
Math.Round
0
 
RIASAuthor Commented:
yes, math.round red squggly
0
 
RIASAuthor Commented:
Severity      Code      Description      Project      File      Line      Suppression State
Error      BC30519      Overload resolution failed because no accessible 'Round' can be called without a narrowing conversion:
0
 
Pawan KumarDatabase ExpertCommented:
Math.Round

put same case I have given.. M and R should be capital , others small..
0
 
AndyAinscowCommented:
Wierd, I made a comment in your last question and it was rejected because it rounded to 2 digits rather than truncated.
d.ToString("0.00")
0
 
RIASAuthor Commented:
Andy,

Sorry just overlooked it.

Cheers!
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

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