Foxtable(狐表)用户栏目专家坐堂 → [求助]打乱组合顺序


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

主题:[求助]打乱组合顺序

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


加好友 发短信
等级:幼狐 帖子:174 积分:2349 威望:0 精华:0 注册:2015/8/12 15:36:00
[求助]打乱组合顺序  发帖心情 Post By:2016/3/8 11:31:00 [只看该作者]

Dim a1 As String = e.Form.Controls("词组1").value
Dim a2 As String = e.Form.Controls("词组2").value
Dim a3 As String = e.Form.Controls("商品名称").value
Dim a4 As String = e.Form.Controls("数量").value

Dim a() As String = a1.Split(",")
Dim b() As String = a2.Split(",")
Dim c() As String = a3.Split(",")
Dim n As Integer = a1.Length - a1.Replace(",","").Length
n = n+1
Dim n1 As Integer = a2.Length - a2.Replace(",","").Length
n1 = n1+1
Dim n2 As Integer = a3.Length - a3.Replace(",","").Length
n2 = n2+1
Dim ls As new List(Of String)
For Index As Integer = 0 To a4
    Dim s As String = a(rand.Next(0,n)) & b(rand.Next(0,n1)) & c(rand.Next(0,n2)) '能否打乱此处的组合顺序?
    If ls.Contains(s) = False
        ls.add(s)
        Dim dr As DataRow
        dr = DataTables("标题设计").AddNew()
        dr("标题") = s
    Else
        index -= 1
    End If
Next


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


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2016/3/8 12:01:00 [只看该作者]

Dim ary() As String = {a(rand.Next(0,n)), b(rand.Next(0,n1)), c(rand.Next(0,n2))}

For j As Integer = 1 To 5 '洗牌次数
    Dim rnum1 As Integer = Rand.Next(ary.Length)
    Dim rnum2 As Integer = Rand.Next(ary.Length)
    Dim temp As String = ary(rnum1)
    ary(rnum1) = ary(rnum2)
    ary(rnum2) = temp
Next
Dim s As String = String.Join("", ary)


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


加好友 发短信
等级:幼狐 帖子:174 积分:2349 威望:0 精华:0 注册:2015/8/12 15:36:00
  发帖心情 Post By:2016/3/8 12:06:00 [只看该作者]

不明白怎么用呵,

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


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2016/3/8 12:27:00 [只看该作者]

汗,替换掉你红色的代码。

 回到顶部