• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 346
  • Last Modified:

Decimal places in a VB program

HI all,

  Okay BRAND NEW to VB and I have a problem I have a percentage that I need to get and I get more than 3 decimals when that's all I need. i.e. 68/52 = 56.667 is what I am looking for but I am getting 56.6666666666667. Please help
Below is my code. This is for the University's Baseball team.

So basically what I need is a calculator that will go to the thousandth power.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim a, b As Integer
        a = tbwon.Text
        b = tblost.Text
        tbresult.Text = ((a / (a + b) * 100))

    End Sub

Open in new window

0
HawaiiDragon
Asked:
HawaiiDragon
1 Solution
 
nepaluzCommented:
change the last line to

tbresult.Text = FormatNumber(((a / (a + b) * 100)),3).ToString

Open in new window

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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