Round a number in Visual Basic .NET

Tags: VB.NET, VB 2008, VB 2010, VB 2012, VB 2013

This code is used to calculate days in 2 dates in Visual basic .net

calculate days

Add the following code to a button click event:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
        Handles Button1.Click
        Dim First As Date
        Dim Second As Date
        Dim Result As New TimeSpan()
        First = DateTimePicker1.Value
        Second = DateTimePicker2.Value
        Result = Second - First
        Me.TextBox1.Text = FormatNumber(Result.TotalDays.ToString, 2)
End Sub


Share This

Home | About | Contact | Privacy Policy

Copyright visual-basic-tutorials.com 2017 - All Rights Reserved.