我正在创建一个具有文本框的表单。在那段文字中,我会要求写一个日期。我的问题是我不想允许日期31-12-9999。怎么办?
答案 0 :(得分:1)
下面的代码将清除文本框,并在输入特定日期的情况下显示错误消息
get_3rd_layer_output = K.function([model.layers[0].input],
layer_outputs[0]) #Extract the element and feed it.
答案 1 :(得分:0)
这是检查输入字符串的另一种方法。此外,此代码还限制了输入错误日期的可能性。
Option Explicit
Private Sub UserForm_Click()
Dim str As String
Dim Counter As Long, i As Long
With UserForm1
str = .TextBox1.Value
If str = "31-12-9999" Then
MsgBox "Invalid date."
Exit Sub
Else
'Test Lenght
If Len(str) <> 10 Then
MsgBox "Please check date's lenght."
Exit Sub
End If
'Test "-" occurance
If Len(str) - Len(Replace(str, "-", "")) <> 2 Then
MsgBox "Please check date's separators."
Exit Sub
End If
'Count Numeric values
For i = 1 To Len(str)
If IsNumeric(Mid(str, i, 1)) Then
Counter = Counter + 1
End If
Next i
If Counter <> 8 Then
MsgBox "Please check number of numberic values in the entered date."
Exit Sub
End If
'Check date validation
If Not IsDate(str) Then
MsgBox "Please check date's day, month or year."
Exit Sub
End If
End If
End With
End Sub