Dim DateTimePicker As New DateTimePicker DateTimePicker.Name = "Start" & counter DateTimePicker.Size = New Size(80, 25) DateTimePicker.Location = New Point(Combo2.Location.X + 135, Combo2.Location.Y) DateTimePicker.ShowUpDown = True DateTimePicker.Value = "1/1/2018 06:00 AM" DateTimePicker.Format = DateTimePickerFormat.Custom DateTimePicker.CustomFormat = "hh:mm tt" Me.Panel2.Controls.Add(DateTimePicker) Dim DateTimePick As New DateTimePicker DateTimePick.Name = "End" & counter DateTimePick.Size = New Size(80, 25) DateTimePick.Location = New Point(DateTimePicker.Location.X + 90, DateTimePicker.Location.Y) DateTimePick.ShowUpDown = True DateTimePick.Value = "1/1/2018 12:00 PM" DateTimePick.Format = DateTimePickerFormat.Custom DateTimePick.CustomFormat = "hh:mm tt" Me.Panel2.Controls.Add(DateTimePick) AddHandler DateTimePick.ValueChanged, AddressOf DateTimePicker2_ValueChanged
Private Sub DateTimePicker2_ValueChanged(ByVal sender As Object, ByVal e As EventArgs) Try Dim cControl As Control Dim counter As Int32 = 0 Dim cControl2 As Control For Each cControl In Me.Panel2.Controls If TypeOf cControl Is DateTimePicker Then counter += 1 If cControl.Name = "Start" & counter Then Dim StartTime As DateTime = cControl.Text If cControl.Name = "End" & counter Then Dim EndTime As DateTime = cControl.Text Dim Duration As TimeSpan = EndTime - StartTime Dim Duration2 = Duration.TotalHours For Each cControl2 In Me.Panel2.Controls If TypeOf cControl2 Is TextBox And cControl2.Name = "Hours" & counter Then cControl2.Text = Duration2 End If Next End If End If End If Next Catch ex As System.Exception MessageBox.Show(ex.Message) End Try End Sub
Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.
When asked, what has been your best career decision?
Deciding to stick with EE.
Being involved with EE helped me to grow personally and professionally.
Connect with Certified Experts to gain insight and support on specific technology challenges including:
We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE