我必須在DateTimePicker
週五前加7天。這是我的代碼。週五加7天?
我知道它會創建一個循環,因爲從週五開始的7天是星期五。然後它重演,我怎麼能阻止它在第一個星期五之後重複?
If Me.DateTimePicker1.Value.DayOfWeek = DayOfWeek.Saturday _
Or Me.DateTimePicker1.Value.DayOfWeek = DayOfWeek.Sunday Then
If Me.DateTimePicker1.Value.DayOfWeek = DayOfWeek.Saturday Then
Me.DateTimePicker1.Value = Me.DateTimePicker1.Value.AddDays(-1)
Else
Me.DateTimePicker1.Value = Me.DateTimePicker1.Value.AddDays(-2)
End If
End If
If Me.DateTimePicker1.Value.DayOfWeek = DayOfWeek.Friday Then
Me.DateTimePicker1.Value = Me.DateTimePicker1.Value.AddDays(7)
End If
End Sub
End Class
我猜這是在變化事件? – Plutonix
是的,那是什麼。你的回答幫了我很多。我對編程和本網站很陌生,非常感謝! – taby