以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 老师给指点一下,排序错在哪里了 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=193388) |
|
-- 作者:xxfoxtable -- 发布时间:2024/9/9 21:36:00 -- 老师给指点一下,排序错在哪里了 Dim Multi As String = "A8,A6,A7,A5" Dim Values() As String Values = Multi.split(",") Dim ls As String = "" Dim j As Integer For i As Integer = 0 To Values.Length - 1 For j = 1 To Values.Length - 1 If Values(i) > Values(j) Then ls = Values(i) Values(i) = Values(j) Values(j) = Ls End If Next Next Dim zf As String = "" For Index As Integer = 0 To Values.Length - 1 If Values(index).Trim <> "" Then If zf = "" Then zf = Values(index) Else zf = zf & "," & Values(index) End If End If Next MessageBox.Show(zf)
|
|
-- 作者:有点蓝 -- 发布时间:2024/9/9 22:16:00 -- Dim Multi As String = "A8,A6,A7,A5" Dim lst As New List(Of String) lst.AddRange(Multi.Split(",")) lst.Sort Dim zf As String = String.Join(",", lst.ToArray) MessageBox.Show(zf)
|
|
-- 作者:xxfoxtable -- 发布时间:2024/9/9 23:01:00 -- Dim Multi As String = "" Dim lst As New List(Of String) lst.AddRange(Multi.Split(",")) MessageBox.Show(lst.Count) 没有元素的情况下lst.count=1,是什么情况呢?
|
|
-- 作者:有点蓝 -- 发布时间:2024/9/9 23:03:00 -- 空字符串也是有效的值 |
|
-- 作者:xxfoxtable -- 发布时间:2024/9/9 23:05:00 -- 那怎么判断,里面有几个元素呢? |
|
-- 作者:有点蓝 -- 发布时间:2024/9/10 8:32:00 -- 判断有没有内容再做后续处理
|
|
-- 作者:xxfoxtable -- 发布时间:2024/9/19 12:50:00 -- 老师这个降序怎么写?
|
|
-- 作者:有点蓝 -- 发布时间:2024/9/19 13:33:00 -- http://www.foxtable.com/webhelp/topics/0217.htm |
|
-- 作者:cd_tdh -- 发布时间:2024/9/19 14:06:00 -- Dim Multi As String = "A8,A6,A7,A5" Dim lst As New List(Of String) lst.AddRange(Multi.Split(",")) lst.Sort() lst.Reverse() Dim zf As String = String.Join(",", lst.ToArray) MessageBox.Show(zf)
|
|
-- 作者:y2287958 -- 发布时间:2024/9/19 15:26:00 -- Output.Show(String.Join(",", "A8,A6,A7,A5".Split(",").OrderByDescending(Function(元素) 元素))) |