Solved

Decimal places in a VB program

Posted on 2011-03-21
1
334 Views
Last Modified: 2012-05-11
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
Comment
Question by:HawaiiDragon
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 17

Accepted Solution

by:
nepaluz earned 500 total points
ID: 35186028
change the last line to

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

Open in new window

0

Featured Post

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

695 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question