Solved

Decimal places in a VB program

Posted on 2011-03-21
1
328 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] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
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.

731 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