Dim str As String = "20150932" Dim d As Date Select Case str.Length Case 4 Date.TryParse(str & "-1-1", d) Case 6 Date.TryParse(str.SubString(0,4) & "-" & str.SubString(5,2) & "-1", d) Case 8 Date.TryParse(str.SubString(0,4) & "-" & str.SubString(4,2) & "-" & str.SubString(6,2), d) End Select If d = Nothing Then msgbox("不是日期") Else msgbox(d) End If