VB.Net program to demonstrate the FromBinary() method of DateTime class

Here, we are going to demonstrate the FromBinary() method of DateTime class in VB.Net.
Submitted by Nidhi, on January 21, 2021

The FromBinary() method is used to create the object of the DateTime class.


Function FromBinary(ByVal bin as Long ) as Date


  • Bin : Specified long value

Return Value: It returns an object of the DateTime class.

Program/Source Code:

The source code to demonstrate the FromBinary() method of the DateTime class is given below. The given program is compiled and executed successfully.

'VB.NET program to demonstrate FromBinary() method of 
'DateTime class.

Imports System

Module Module1
    Sub Main()
        Dim date1 As New DateTime(2020, 4, 27, 10, 20, 30)
        Dim date2 As New DateTime()

        Dim bin As Long = 0

        bin = date1.ToBinary()

        date2 = DateTime.FromBinary(bin)

        Console.WriteLine("Binary value: {0}", bin)
        Console.WriteLine("Date: {0}", date2)
    End Sub
End Module


Binary value: 637235796300000000
Date: 27-04-2020 10:20:30
Press any key to continue . . .


In the above program, we created a module Module1 that contains the Main() function. The Main() function is the entry point for the program.

In the Main() function, we created an object of the DateTime class and converted the date object into 64-bit binary using ToBinary() method and then get the Date object from 64-bit binary value. After that print the date on the console screen.

VB.Net Date & Time Programs »


Comments and Discussions!


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

© some rights reserved.