Solved

# convert double to integer

Posted on 2006-06-30
400 Views
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
Question by:newyuppie
[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
• 2
• 2

LVL 18

Accepted Solution

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

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

LVL 18

Expert Comment

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

ID: 17022292
thank you!
0

## Featured Post

Question has a verified solution.

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

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
###### Suggested Courses
Course of the Month6 days, 6 hours left to enroll