不能, 试试 Private Sub DTPicker1_CloseUp() DTPicker1.Value = DateAdd("d", -Weekday(DTPicker1.Value, vbMonday) + 1, DTPicker1.Value) End Sub
Dim mDate As Date Private Sub Form_Load() mDate = DTPicker1.Value End Sub Private Sub DTPicker1_CloseUp() If Weekday(DTPicker1.Value) <> vbMonday Then DTPicker1.Value = mDate End If End Sub
CloseUp 不能禁止键盘输入的变更,标准做法: Private Sub DTPicker1_Validate(Cancel As Boolean) If DTPicker1.DayOfWeek <> vbMonday Then MsgBox "只能选星期一", vbExclamation Cancel = True End If End Sub
Private Sub DTPicker1_Validate(Cancel As Boolean) If DTPicker1.DayOfWeek <> vbMonday Then MsgBox "只能选星期一", vbExclamation Cancel = True End If End Sub
试试
Private Sub DTPicker1_CloseUp()
DTPicker1.Value = DateAdd("d", -Weekday(DTPicker1.Value, vbMonday) + 1, DTPicker1.Value)
End Sub
Private Sub Form_Load()
mDate = DTPicker1.Value
End Sub
Private Sub DTPicker1_CloseUp()
If Weekday(DTPicker1.Value) <> vbMonday Then
DTPicker1.Value = mDate
End If
End Sub
Private Sub DTPicker1_Validate(Cancel As Boolean)
If DTPicker1.DayOfWeek <> vbMonday Then
MsgBox "只能选星期一", vbExclamation
Cancel = True
End If
End Sub
If DTPicker1.DayOfWeek <> vbMonday Then
MsgBox "只能选星期一", vbExclamation
Cancel = True
End If
End Sub