Member Avatar for Micheal87

Hi, I have a little issues, while auto-refresh all values (remaing time), in summary the program pick the datatime stored in a combobox then subtract it with current time (datetime.now) and return the value (remaining time) stored in another one combobox. The issues is that when I click the refresh button only the last item on the remaining time combobox will change. I need that it will change from the first and so on till the last, using the date previously stored in the combobox. Do I need to store previous value in a temp variable?

 Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
       For i = 0 To ComboBox3.Items.Count - 1
        ComboBox3.SelectedIndex = i
        Dim d As DateTime = DateTime.Now
        Dim parsedate As DateTime = ComboBox2.SelectedItem.ToString
        Dim d2 As DateTime = DateTime.ParseExact(parsedate, "dd/MM/yyyy HH:mm:ss", System.Globalization.CultureInfo.CurrentCulture)
        Dim dysdiff As Integer = (d - d2).Days
        ComboBox3.Items(i) = (365 - dysdiff).ToString + " Days"
    Next

End Sub
Member Avatar for Micheal87

EDIT: the event will fire correctly only when pressed two times the button
Still waiting for a more good solution

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.