2016-12-25 105 views

回答

2

這是因爲該字符串bbb不包含字符*@*@*的序列。

String.Contains不支持通配符。

你可以用它來代替。

If Regex.Match(bbb,".*@.*@.*").Success then 
    MsgBox("Error2") 
End If 
1

您不能使用通配符。

包含不支持*通配符。也許試試這個?

If bbb.Contains("@") And bbb.IndexOf("@") <> bbb.LastIndexOf("@") Then 
    ... 
End If 
0

您可以使用.count()確定@的發生,並相應地顯示信息。

Dim bbb As String = "[email protected]@cc" 
    Dim cnt As Integer 

    cnt = bbb.Count(Function(x) x = "@") 'Number of @ in the string 

    If cnt = 1 Then 
    MsgBox("Error1") 
    ElseIf cnt = 2 Then 
    MsgBox("Error2") 
    End If 

注:我認爲OP在字符串尋找人物的出現,而不是特定的模式應遵循