ADVERTISEMENT
ADVERTISEMENT

VB.Net program to print the difference of two times

Here, we are going to learn how to print the difference of two times in VB.Net?
Submitted by Nidhi, on January 19, 2021

Here, we will calculate the difference of two times and print the result on the console screen.

Program/Source Code:

The source code to print the difference of two times is given below. The given program is compiled and executed successfully.

'VB.NET program to print the difference of two times.

Imports System

Module Module1
    Sub Main()
        Dim time As TimeSpan
        Dim ts1 As New TimeSpan(12, 20, 30)
        Dim ts2 As New TimeSpan(10, 20, 10)

        time = ts1 - ts2

        Console.WriteLine("Hours:{0}, Minutes:{1}, Seconds:{2}", time.Hours, time.Minutes, time.Seconds)
    End Sub
End Module

Output:

Hours:2, Minutes:0, Seconds:20
Press any key to continue . . .

Explanation:

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 two objects of the TimeSpan class and initialized them with time values. After that, we calculated the difference between the two times and print the result on the console screen.

VB.Net Date & Time Programs »



ADVERTISEMENT



ADVERTISEMENT



Comments and Discussions


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.