Round a string to two digits

Hello,

How can I round a number to 2 digits

Cheers
RIASAsked:
Who is Participating?
 
AndyAinscowConnect With a Mentor Freelance programmer / ConsultantCommented:
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
 
Pawan KumarDatabase ExpertCommented:
Sample example pls?
0
 
RIASAuthor Commented:
500.999
400.789
0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

 
Pawan KumarDatabase ExpertCommented:
Output should be below correct ?

501.00
400.80
0
 
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 KumarConnect With a Mentor Database ExpertCommented:
Math.Round

put same case I have given.. M and R should be capital , others small..
0
 
RIASAuthor Commented:
Andy,

Sorry just overlooked it.

Cheers!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.