Solved

Double

Posted on 2008-06-25
3
179 Views
Last Modified: 2010-04-23
How can I get a result like :  19.53 % instead of 19.53125%  when dividing number and get a %?


dim i as integer = 100
dim x as integer  = 5.12
dim tl as double ?

tl = i / x
0
Comment
Question by:VBdotnet2005
[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
  • 2
3 Comments
 
LVL 48

Accepted Solution

by:
jpaulino earned 50 total points
ID: 21870929
Hi VBdotnet2005,

Try this way:
        Dim i As Double = 100
        Dim x As Double = 5.12
        Dim tl As Double = (i / x) / 100
        Debug.WriteLine(FormatPercent(tl.ToString))

Open in new window

0
 
LVL 10

Assisted Solution

by:margajet24
margajet24 earned 50 total points
ID: 21871662
tl = (Double)i / (Double)x

type cast both i and x to double first..
0
 
LVL 10

Expert Comment

by:margajet24
ID: 21871677
tl = CDbl(i) / CDbl(x)
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

696 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