|
没有调试,自己测试一下吧,仅供参考。。。- Function HasPunctuation(ByVal str As String) As Boolean
- Dim punctuations As String
- Dim i As Long
- ' 定义标点符号字符集,这个你自己根据需要进行修改
- punctuations = ".,;:?!-~`'""()[]{}<>/\,。;:?!()【】{}"
- For i = 1 To Len(str)
- If InStr(punctuations, Mid(str, i, 1)) > 0 Then
- HasPunctuation = True
- Exit Function
- End If
- Next i
- HasPunctuation = False
- End Function
- Sub Test()
- Dim myString As String
- Dim result As Boolean
- myString = "半场结束时,湖人领先掘金8分。"
- result = HasPunctuation(myString)
- If result Then
- MsgBox "字符串中包含标点符号。"
- Else
- MsgBox "字符串中不包含标点符号。"
- End If
- End Sub
复制代码
|
评分
-
3
查看全部评分
-
|