Private Sub Command1_Click() Dim strTest As String, strTest1 As String strTest = "我10好" strTest1 = "123106" MsgBox IsCheckString(strTest) End SubPrivate Function IsCheckString(ByVal strCheck As String) As Boolean Dim intStart As Integer, intEnd As Integer intStart = InStr(strCheck, "10") If intStart > 0 Then If IsNumeric(Mid(strCheck, intStart - 1, 1)) Then IsCheckString = False Exit Function Else If IsNumeric(Mid(strCheck, intStart + Len("10") + 1, 1)) Then IsCheckString = False Exit Function End If End If Else IsCheckString = False Exit Function End If IsCheckString = True End Function
Dim strTest As String, strTest1 As String
strTest = "我10好"
strTest1 = "123106"
MsgBox IsCheckString(strTest)
End SubPrivate Function IsCheckString(ByVal strCheck As String) As Boolean
Dim intStart As Integer, intEnd As Integer
intStart = InStr(strCheck, "10")
If intStart > 0 Then
If IsNumeric(Mid(strCheck, intStart - 1, 1)) Then
IsCheckString = False
Exit Function
Else
If IsNumeric(Mid(strCheck, intStart + Len("10") + 1, 1)) Then
IsCheckString = False
Exit Function
End If
End If
Else
IsCheckString = False
Exit Function
End If
IsCheckString = True
End Function