Solved

Decimal places in a VB program

Posted on 2011-03-21
1
288 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
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
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 viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
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.

757 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now