以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  [求助]打乱组合顺序  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=81883)

--  作者:农村人
--  发布时间: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


--  作者:大红袍
--  发布时间: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)


--  作者:农村人
--  发布时间:2016/3/8 12:06:00
--  
不明白怎么用呵,
--  作者:大红袍
--  发布时间:2016/3/8 12:27:00
--  
汗,替换掉你红色的代码。