Foxtable(狐表)用户栏目专家坐堂 → [求助]字符串数组


  共有2271人关注过本帖树形打印复制链接

主题:[求助]字符串数组

帅哥哟,离线,有人找我吗?
天一生水
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:五尾狐 帖子:1141 积分:11272 威望:0 精华:0 注册:2017/9/26 16:30:00
[求助]字符串数组  发帖心情 Post By:2018/9/3 22:24:00 [显示全部帖子]

想替换字符串中的句号,末尾的句号除外,请蓝老师帮忙改一下,谢谢!
代码结果为"你好,你好,你好。"

'''
Dim str As String = "你好,你好。你好。"
.......

Dim lst As new List(Of String)
If lst.Count >= 1 Then
    For i As Count = 0 To lst.Count-1
        If i <> lst.Count -1 Then
            lst(i).Replace("。",",")
        End If
    Next
End If
Output.Show(lst)


 回到顶部
帅哥哟,离线,有人找我吗?
天一生水
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:五尾狐 帖子:1141 积分:11272 威望:0 精华:0 注册:2017/9/26 16:30:00
  发帖心情 Post By:2018/9/4 11:56:00 [显示全部帖子]

1、这样没问题:

'''
Dim str As String = "在控件中每输入,或删除一个字符。都会触发TextChanged事件,"
str = str.TrimEnd("。").TrimEnd(",").TrimEnd(";").Replace(":","").Replace(";",",").Replace(",",",").Replace("、",",").Replace("。",",") & "。"
Output.Show(str)

 

2、文本框textchang代码,在文本框中编辑时为什么出现一些句号单独成了一段,也删不掉:

Dim txt As WinForm.TextBox = e.Form.Controls("TextBox01")
If txt.text.EndsWith(chr(10)) = False Then
    Dim ary() As String = txt.Text.Split(chr(13))
    Dim str As String = ""
    For Each s As String In ary

        s =s.TrimEnd("。").TrimEnd(",").TrimEnd(";").Replace(":","").Replace(";",",").Replace(",",",").Replace("、",",").Replace("。",",") & "。"
        If s <> chr(10) Then
            str &= "    " & s.trim & vbcrlf '行首空格
            str &= vbcrlf & ""
        End If
    Next
    systemready = False
    txt.text = str
    systemready = True
End If




 回到顶部