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


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

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

帅哥哟,离线,有人找我吗?
天一生水
  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


加好友 发短信
等级:超级版主 帖子:110642 积分:563118 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2018/9/3 22:29:00 [只看该作者]

lst(i) = lst(i).TrimEnd("。").Replace("。",",") & "。"

 回到顶部
帅哥哟,离线,有人找我吗?
天一生水
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | 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




 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2018/9/4 12:22:00 [只看该作者]

'''
Dim txt As WinForm.TextBox = e.Form.Controls("TextBox2")
Dim ary() As String = txt.Text.replace(chr(10), "").Split(chr(13))
Dim str As String = ""
For Each s As String In ary
    If s.trim > "" Then
        s =s.TrimEnd("。").TrimEnd(",").TrimEnd(";").Replace(":","").Replace(";",",").Replace(",",",").Replace("、",",").Replace("。",",") & "。"
    End If
   
    str &= "    " & s.trim & vbcrlf '行首空格
Next
systemready = False
txt.text = str
systemready = True

 回到顶部