Lan Solo Posted June 13, 2003 Posted June 13, 2003 I am having a heck of a time getting the DateDiff result (if it's even being calculated) to pull from the mlngNumberOfDays variable and display it in the text box. Any hints would be appreciated. 'Here are the variables that are applicable to the above mentioned problem Private mlngNumberOfDays As Long Private mdatStartDate As Date Private mdatEndDate As Date 'Here is the event handler Private Sub Calculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click mlngNumberOfDays = DateDiff(DateInterval.Day, mdatStartDate, mdatEndDate) Thanks Quote
wyrd Posted June 13, 2003 Posted June 13, 2003 http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdatetimeclasstopic.asp Dim date1 As New System.DateTime(1996, 6, 3, 22, 15, 0) Dim date2 As New System.DateTime(1996, 12, 6, 13, 2, 0) Dim date3 As New System.DateTime(1996, 10, 12, 8, 42, 0) Dim diff1 As System.TimeSpan ' diff1 gets 185 days, 14 hours, and 47 minutes. diff1 = date2.Subtract(date1) Dim date4 As System.DateTime ' date4 gets 4/9/1996 5:55:00 PM. date4 = date3.Subtract(diff1) Dim diff2 As System.TimeSpan ' diff2 gets 55 days 4 hours and 20 minutes. diff2 = System.DateTime.op_Subtraction(date2, date3) Dim date5 As System.DateTime ' date5 gets 4/9/1996 5:55:00 PM. date5 = System.DateTime.op_Subtraction(date1, diff2) If I'm not mistaken, you can also do; Dim numOfDays As Integer = date1 - date2 Quote Gamer extraordinaire. Programmer wannabe.
Lan Solo Posted June 13, 2003 Author Posted June 13, 2003 OK I changed the variable and the corresponding event handler to: Private mintNumberOfDays As Integer Private Sub Calculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click NumberOfDays.Text = DateDiff(DateInterval.Day, mdatStartDate, mdatEndDate) and the autos windows is giving me these messages: mdatEndDate #12:00:00 AM# Date mdatStartDate #12:00:00 AM# Date mlngNumberOfDays 0 Long radStandard Nothing System.Windows.Forms.RadioButton Quote
Leaders dynamic_sysop Posted June 13, 2003 Leaders Posted June 13, 2003 Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click Dim strStart As String = "11/06/2003 09:10:45" Dim strCurrent As Date Dim mintNumberOfDays As Integer = DateDiff(DateInterval.Day, Convert.ToDateTime(strStart), strCurrent.Now) MessageBox.Show("the date difference is : " & mintNumberOfDays) End Sub Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.