如何判断字符串是否yyyy-mm-dd格式
vb 如题
[解决办法]
Function b(s As String) As Boolean
On Error GoTo 100
If s = Format(CDate(s), "yyyy-mm-dd ") Then
b = True
Else
b = False
End If
Exit Function
100:
b = False
End Function
Private Sub Command1_Click()
Dim s As String
s = "2006-3-13 "
MsgBox b(s)
s = "04/01/2006 "
MsgBox b(s)
s = "2006/04/30 "
MsgBox b(s)
s = "2006-18-51 "
MsgBox b(s)
s = "2006-04-30 "
MsgBox b(s)
End Sub
是不是要这个?
[解决办法]
Dim reg,str,match,Matches
str= "2007-04-30 "
Set reg=new regexp
reg.IgnoreCase = True
reg.pattern= "^\d{4}-\d{2}-\d{2}$ "
Set Matches = reg.Execute(str)
If(CInt(Matches.count)> =1) Then
MsgBox "匹配 "
Else
MsgBox "不匹配 "
End If
怎么判断字符串是否yyyy-mm-dd格式
如何判断字符串是否yyyy-mm-dd格式vb如题[解决办法]Function b(s As String) As BooleanOn Error GoTo 100
