Google
 
Web undim.blogspot.com
Visual Basic developer's world

Monday, March 01, 2010
How to convert a long number to double and vice versa
The function that you could use to convert a long number to double is :
cDbl

Example source code:

Dim dblMyNumber As Double
Dim lngMyNumber As Long

lngMyNumber = 1002992

dblMyNumber = CDbl(lngMyNumber)


Thus lngMyNumber was converted to a double using CDbl. The output double variable is dblMyNumber.

Now, to convert a Double to a long, you need cLng function.
cLng (Convert to Long) is used like in the following example:

Example source code:

Dim dblMyNumber As Double
Dim lngMyNumber As Long

dblMyNumber = 1002992

lngMyNumber = CLng(dblMyNumber)


So dblMyNumber was converted to a Long using CLng. The output double variable is lngMyNumber.

NOTICE:
The Long data type is a 32-bit number
It ranges from -2,147,483,648 to 2,147,483,647.
Long variables can only contain non-fractional integer values.

The Double data type is a 64-bit floating point number used when high accuracy is needed.
These variables can range from -1.79769313486232e308 to -4.94065645841247e-324 for negative values and from 4.94065645841247e-324 to 1.79769313486232e308 for positive values.

This means that you might face overflow issues because Double has the double size than Long datatype.

Take a look at the following code:

Dim dblMyNumber As Double
Dim lngMyNumber As Long

dblMyNumber = 3147483647#

lngMyNumber = CLng(dblMyNumber)


Labels: , , , , , ,


posted by Admin @ 2:30 AM  
7 Comments:
  • At 7:06 PM, Blogger jacques said…

    guys do you know how to modifier the help in the main menu in Visual Basic program?

    Thx,

     
  • At 2:27 AM, Blogger Jeffy said…

    Thank you for sharing the information here. Its much informative and really i got some valid information.

    SEO Company in Chennai

     
  • At 4:19 AM, Blogger Keerthi said…

    It’s really amazing that we can record what our visitors do on our site. Thanks for sharing this awesome guide. I’m happy that I came across with your site this article is on point,thanks again and have a great day. Keep update more information..

    Online Training in Chennai

     
  • At 12:42 AM, Blogger Kalpu Kvb said…

    Very happy to see this blog. Gives a wonderful information with coded explanaion. Thank you for this blog. very useful to me.
    PPC Services Chennai

     
  • At 4:07 AM, Blogger vinu priya said…

    Wonderful blog.. Thanks for sharing informative blog.. its very useful to me.. Mobile App Development Company in Chennai

     
  • At 12:06 AM, Blogger Nandhini said…

    Very nice post here and thanks for it .I always like and such a super contents of these post.Excellent and very cool idea and great content of different kinds of the valuable information's.
    Housekeeping Services in Chennai

     
  • At 6:01 PM, Blogger buyket said…


    تعد خدمات التنظيف المتعلقه بالمنزل بصفه عامه ان الامور الهامه حاليا لما لها من ترابط وثيق بالصحه والقضاء علي الامراض وخصيصا تنظيف الخزانات والتي تعد من الضروريات حيث يجب تنظيفها بصفه دوري
    شركة تنظيف بالخرج
    فان كنت عميلنا الكريم من الرياض او الخرج او جده فنحن نوفر لك افضل خدمات التنظيف العامه بمعدات حديثه وعماله مدربه

     

Post a Comment

Important


Don't spam. Your spam posts are always removed.



<< Home
 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 
About Me

Name: Admin
Home: The NeverLands
About Me: A source code wonderer since the early 80s with my first ZX81 by Sinclair, home computer.
See my complete profile
Previous Post
Archives
Must-See Places
ΣΚΛΗΡΥΝΣΗ ΚΑΤΑ ΠΛΑΚΑΣ - ΕΓΚΕΦΑΛΟΣ - ΕΓΚΕΦΑΛΟΓΡΑΦΗΜΑ - ΑΝΟΙΑ - ΝΕΥΡΟΛΟΓΟΣ - ΨΥΧΙΑΤΡΟΣ - ΛΟΙΜΩΔΗΣ ΜΟΝΟΠΥΡΗΝΩΣΗ - ΠΑΡΚΙΝΣΟΝ - ΑΓΧΟΣ - ΚΑΤΑΘΛΙΨΗ - ALZHEIMER - EPSTEIN BARR eurolife
e-LaUgHs :-)
Template By
Free Blogger templates