Solved

convert double to integer

Posted on 2006-06-30
4
395 Views
Last Modified: 2010-08-05
vb2005

i finally decided to turn option strict on, and i get a bunch of implicit conversion warnings. what is the best way to convert a Double to an Integer, without using microsoft.visualbasic namespace?
0
Comment
Question by:newyuppie
  • 2
  • 2
4 Comments
 
LVL 18

Accepted Solution

by:
Ravi Singh earned 250 total points
ID: 17021997
You could use the Convert class:

        Dim dNum As Double = 10.4
        Dim iNum As Integer = Convert.ToInt32(dNum)
0
 
LVL 13

Author Comment

by:newyuppie
ID: 17022010
perfect, so that would also truncate the decimals right? no need for convert.toint32(math.truncate(dnum))?
0
 
LVL 18

Expert Comment

by:Ravi Singh
ID: 17022028
Hi,

Convert.ToInt32 will round up from above .5, if you only want the integral part of the number then you'll have to call the truncate method.

0
 
LVL 13

Author Comment

by:newyuppie
ID: 17022292
thank you!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

911 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

22 Experts available now in Live!

Get 1:1 Help Now