ADVERTISEMENT
ADVERTISEMENT

VB.Net program to convert a double number into an integer number

Here, we are going to learn how to convert a double number into an integer number in VB.Net?
Submitted by Nidhi, on November 26, 2020

We will create a program in VB.Net to convert a double number into an integer number using Int() function.

Program/Source Code:

The source code to convert a double number into an integer number is given below. The given program is compiled and executed successfully.

'VB.Net program to convert a double number 
'to integer number.

Module Module1
    Sub Main()
        Dim a As Double = 123456.789
        Dim b As Integer = 0
        
        'type conversion
        b = Int(a)
        
        Console.WriteLine("value of a: {0}", a)
        Console.WriteLine("value of b: {0}", b)
        
        'hit ENTER to exit the program
        Console.ReadLine()
    End Sub
End Module

Output:

value of a: 123456.789
value of b: 123456

Explanation:

Here, we created a Module that contains the Main() method, here we created two local variables a and b that is initialized 123456.789 and 0 respectively.

b = Int(a)

Console.WriteLine("value of a: {0}", a)
Console.WriteLine("value of b: {0}", b)

Here, we converted the value double variable a into integer variable b using the Int() function. After that, we printed the value of a and b on the console screen.

VB.Net Basic Programs »



ADVERTISEMENT




ADVERTISEMENT



Comments and Discussions!

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.