Foxtable(狐表)用户栏目专家坐堂 → 循环代码求助


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

主题:循环代码求助

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


加好友 发短信
等级:小狐 帖子:372 积分:3193 威望:0 精华:0 注册:2018/3/15 16:46:00
循环代码求助  发帖心情 Post By:2022/5/14 11:34:00 [只看该作者]

Dim Products As List(Of String)
Products = DataTables("客户").GetValues("客户名称")

Products集合中获得的值是:"张三","李四","王五","赵六","大卫","小伟","秘鲁","里奇","可达","披露","问止",
我想通过一个数值变量使它重新排列,比如这个数值是5,重新排列的结果是:
"里奇","可达","披露","问止","张三","李四","王五","赵六","大卫","小伟","秘鲁"
另外一个结果是:
"大卫","赵六","王五","李四","张三","问止","披露","可达","里奇","秘鲁","小伟"

求助这个循环要怎么写?

 回到顶部
帅哥,在线噢!
有点蓝
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:110582 积分:562806 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2022/5/14 12:13:00 [只看该作者]

Dim sr() As String = {"张三", "李四", "王五", "赵六", "大卫", "小伟", "秘鲁", "里奇", "可达", "披露", "问止"}
Dim a As Integer = 5
Dim lst As New List(Of String)
For i As Integer = a To sr.Length - 1
    lst.add(sr(i))
Next 
For i As Integer = 0 To a - 1
    lst.add(sr(i))
Next 
For Each s As String In lst
    Output.Show(s)
Next 
Dim lst2 As New List(Of String)
For i As Integer = a To 0 Step - 1
    lst2.add(sr(i))
Next 
For i As Integer = sr.Length - 1 To a + 1 Step - 1
    lst2.add(sr(i))
Next 
For Each s As String In lst2
    Output.Show(s)
Next 

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


加好友 发短信
等级:小狐 帖子:372 积分:3193 威望:0 精华:0 注册:2018/3/15 16:46:00
  发帖心情 Post By:2022/5/14 13:02:00 [只看该作者]

Dim sr() As String = {"张三", "李四", "王五", "赵六", "大卫", "小伟", "秘鲁", "里奇", "可达", "披露", "问止"}

这一句用集合行不行?因为这个都是从数据表中提出来的集合。

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


加好友 发短信
等级:小狐 帖子:372 积分:3193 威望:0 精华:0 注册:2018/3/15 16:46:00
  发帖心情 Post By:2022/5/14 13:03:00 [只看该作者]

以下是引用有点蓝在2022/5/14 12:13:00的发言:
Dim sr() As String = {"张三", "李四", "王五", "赵六", "大卫", "小伟", "秘鲁", "里奇", "可达", "披露", "问止"}
Dim a As Integer = 5
Dim lst As New List(Of String)
For i As Integer = a To sr.Length - 1
    lst.add(sr(i))
Next 
For i As Integer = 0 To a - 1
    lst.add(sr(i))
Next 
For Each s As String In lst
    Output.Show(s)
Next 
Dim lst2 As New List(Of String)
For i As Integer = a To 0 Step - 1
    lst2.add(sr(i))
Next 
For i As Integer = sr.Length - 1 To a + 1 Step - 1
    lst2.add(sr(i))
Next 
For Each s As String In lst2
    Output.Show(s)
Next 

我用表事件的GetValues只能提出集合


 回到顶部
帅哥,在线噢!
有点蓝
  5楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:110582 积分:562806 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2022/5/14 13:34:00 [只看该作者]

可以的,用法完全一样。这种自己试试就知道了

 回到顶部