DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   VB.NET (http://www.daniweb.com/forums/forum58.html)
-   -   Label not changing (http://www.daniweb.com/forums/thread118263.html)

kahaj Apr 9th, 2008 1:24 pm
Label not changing
 
I have this program that I thought was complete. Apparently not. The info in lasVegasTimeLabel.Text isn't changing when the info in dropOffDateTimePicker is manipulated.

Public Class shippingForm

  Private Sub clockTimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles clockTimer.Tick
      'print current time
      currentTimeLabel.Text = String.Format("{0:hh:mm:ss tt}", Date.Now)
  End Sub

  Private Sub shippingForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
      Dim currentTime As Date = Date.Now 'store current time

      'set range of poss drop-off times
      dropOffDateTimePicker.MinDate = New Date(currentTime.Year, currentTime.Month, _
        currentTime.Day, 0, 0, 0)

      dropOffDateTimePicker.MaxDate = dropOffDateTimePicker.MinDate.AddDays(1)

      'display the delivery time
      DisplayDeliveryTime()
  End Sub

  Private Sub dropOffDateTimePicker_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles dropOffDateTimePicker.ValueChanged
      'display deliv time
      DisplayDeliveryTime()
  End Sub

  'calculates and displays deliv time
  Sub DisplayDeliveryTime()
      'print init deliv time
      Dim delivery As Date = DepartureTime()

      'add 3 hours to departure and display
      delivery = delivery.AddHours(3)
      lasVegasTimeLabel.Text = delivery.ToLongDateString & " at " & delivery.ToShortDateString
  End Sub

  'return flight departure time for slected dorp-off time
  Function DepartureTime() As Date

      Dim currentDate As Date = Date.Now 'store cur date
      Dim departTime As Date  'store depart time

      'determine which flight teh shipment takes
      Select Case dropOffDateTimePicker.Value.Hour
        'seafood will be on noon flight
        Case 0 To 10
            departTime = New Date(currentDate.Year, currentDate.Month, currentDate.Day, _
              12, 0, 0)
            'seafood will be on tomorrow's noon flight
        Case 23
            currentDate = currentDate.AddDays(1)
            departTime = New Date(currentDate.Year, currentDate.Month, currentDate.Day, _
              12, 0, 0)
            'seafood will be on midnight flight
        Case Else
            currentDate = currentDate.AddDays(1)
            departTime = New Date(currentDate.Year, currentDate.Month, currentDate.Day, _
              0, 0, 0)
      End Select
      Return DepartureTime
  End Function
End Class ' ShippingTimeForm

What am I missing here?


All times are GMT -4. The time now is 8:29 pm.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC