Solved

convert double to integer

Posted on 2006-06-30
4
401 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
[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
  • 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

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

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…
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

726 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