Rss & SiteMap

Foxtable(狐表) http://www.foxtable.com

新一代数据库软件,完美融合Access、Foxpro、Excel、vb.net之优势,人人都能掌握的快速软件开发工具!
共4 条记录, 每页显示 10 条, 页签: [1]
[浏览完整版]

标题:[求助]代码问题

1楼
ezilu 发表于:2023/12/11 20:02:00
表属性,datacolchanged事件:

        Dim dr As DataRow
        dr = DataTables("TypeA1").Find("[Qid] = '" & e.NewValue & "'")
        If dr IsNot Nothing Then
            Dim opt As String = dr("Opt") 'dr("Opt")是一组用|分割的字符串
            Dim opts() As String
            opts = opt.split("|") '分隔符,把单元格字符串变成数组
            Dim cnt As Integer = opts.Length '数组个数
            '根据数组个数,生成一个打乱顺序的集合,比如数组个数是5个,我需要生成一个集合{0,1,2,3,4},而且是打乱顺序的,再把这5个数组填入表格中
            Dim ids1 As New List(Of Integer) '用于存储洗牌前的位置
            Dim ids2 As New List(Of Integer) '用于存储洗牌后的位置
            For i As Integer = 0 To cnt - 1 '准备初始的牌
                ids1.add(i)
            Next
            For i As Integer = 0 To cnt - 1 '开始洗牌
                Dim idx As Integer = ids1(rand.Next(0, ids1.count))
                ids2.Add(idx)
                ids1.Remove(idx)
            Next
            Dim Arys() As Integer
            Arys = ids2.ToArray() '将集合转换为数组
            Dim xxpx As String '新序
            xxpx = String.Join(",", Arys)
            e.DataRow("Xxpx") = xxpx
        End If

这段码是不是可以简化呀  各位大神,我是见招拆招,谢谢麻烦各位大神了

内容一|内容二|内容三|内容四|内容五    2,1,3,0,4  


[此贴子已经被作者于2023/12/11 20:04:04编辑过]
2楼
有点蓝 发表于:2023/12/11 20:43:00
没看懂,请上传实例,说明要做什么功能
3楼
ezilu 发表于:2023/12/11 21:17:00
内容一|内容二|内容三|内容四|内容五    2,1,3,0,4  
意思就是在表属性的datacolchanged里面
如何实现:
当你在左边单元格输入N个以|分割的内容后
自动在右边单元格里面填入从0至n-1的整数字

大神,谢谢
[此贴子已经被作者于2023/12/11 21:18:13编辑过]
4楼
有点蓝 发表于:2023/12/11 21:55:00
就是1楼的用法了,无法简化
共4 条记录, 每页显示 10 条, 页签: [1]

Copyright © 2000 - 2018 foxtable.com Tel: 4000-810-820 粤ICP备11091905号

Powered By Dvbbs Version 8.3.0
Processed in .02344 s, 2 queries.