以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 在字符窜里,怎么保证唯一值呢? (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=60196) |
-- 作者:qianqian1530 -- 发布时间:2014/11/19 21:10:00 -- 在字符窜里,怎么保证唯一值呢? 字符窜是用 “,” 分割的。 dim des as string ="1,2,1,3,5,6,7" 1是重复的, 怎么才能删除呢? *重复可能多个
[此贴子已经被作者于2014-11-19 21:10:37编辑过]
|
-- 作者:有点甜 -- 发布时间:2014/11/19 21:13:00 -- Dim des As String = "1,2,1,3,5,6,7" Dim ary() As String = des.Split(",") Dim ls As new List(of String) For Each s As String In ary If ls.Contains(s) = False Then ls.Add(s) End If Next msgbox(ls.count)
|
-- 作者:qianqian1530 -- 发布时间:2014/11/19 21:31:00 -- 我想要的效果 是 这个 Dim des As String = "1,2,1,1,1,1,1,1,3,53,53,53,53,53,5,5,56,7" Dim des2 As String Dim ary() As String = des.Split(",") Dim ls As new List(of String) For Each s As String In ary If ls.Contains(s) = False Then ls.Add(s) des2 + = "," & s End If Next des2 = des2.Trim(",") msgbox(des2) |