vb.net按式样比较字符串

‘#’ 单个数字
‘?’ 单个字符
‘*’ 任意字符
[charlist] 字符列表中的单个字符
[!charlist] 非字符列表中的单个字符

举例:
“#123” LIke “#23” True
(但是“#23” LIke “#123” False)
“Hello” Like “H?llo” True
“Hello” Like “H*” True
“X” Like “[D-Z]” False
“X” LIke “[!D-Z]” False
代码实际演示:

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim result As Boolean
        result = "1123" Like "#123"
        Label1.Text = result
    End Sub

result1

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim result As Boolean
        result = "#123" Like "1123"
        Label1.Text = result
    End Sub

result2

有时间需要认真总结一下vb的字符串比较问题,比如vb变量不区分大小写,字符串区分吗?
Like, equals()、compareTo、直接相等(‘=’单等号的用法,‘==’ 双等号的用法),有什么区别具体怎么用

posted @ 2019-05-26 18:10  爱做梦的子浩  阅读(262)  评论(0编辑  收藏  举报