以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  请教:如何遍历字符串里的字符?  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=77500)

--  作者:bahamute
--  发布时间:2015/11/19 11:58:00
--  请教:如何遍历字符串里的字符?
想要判断一个字符串里的字符是否一致,比如888888,,或者aaaaaa
--  作者:大红袍
--  发布时间:2015/11/19 12:33:00
--  

Dim str As String = "8888488"

Dim flag As Boolean = True
Dim ps As String = ""
For Each s As String In str
    If ps <> "" AndAlso ps <> s Then
        msgbox(s)
        flag = False
        Exit For
    End If
    ps = s
Next

msgbox(flag)


--  作者:don
--  发布时间:2015/11/19 12:41:00
--  
Dim s1,s2 As String
s1="aaaaaaa"

If s1 IsNot Nothing Then
    s2 =s1.replace(s1.SubString(0,1),"")
    If s2 = Nothing Then
        Output.Show("YES!")
    Else
        Output.Show("No!")
    End If
End If

--  作者:Hyphen
--  发布时间:2015/11/19 12:53:00
--  
Dim s1 As String = "8888888"
If Not String.IsNullorEmpty(s1) Then
    If String.IsNullorEmpty(s1.Trim(s1(0))) Then
        Output.Show("同样")
    Else
        Output.Show("不同样")
    End If
End If
[此贴子已经被作者于2015/11/19 12:54:55编辑过]

--  作者:lsy
--  发布时间:2015/11/19 14:05:00
--  
Dim s As String = "88888"
If s > "" Then
    MessageBox.Show(s.Replace(s(0),"") = "")
End If

--  作者:bahamute
--  发布时间:2015/11/19 17:26:00
--  
几位大神的法子都OK,非常感谢图片点击可在新窗口打开查看