以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 自动输入 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=191395) |
-- 作者:wlj88868 -- 发布时间:2024/4/14 13:11:00 -- 自动输入 Dim n As Integer = 14 \'要生成密码长度 Dim str() As String = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S" , "T", "U", "V", "W", "X", "Y", "Z"} For i As Integer = 1 To str.Length \'洗牌测次数 Dim n1 As Integer = Rand.Next(str.Length) Dim n2 As Integer = Rand.Next(str.Length) Dim temp As String = str(n1) str(n1) = str(n2) str(n2) = temp Next Dim s As String = String.Join("", str) If n > s.Length Then n = s.Length End If Output.Show(s.Substring(0, n))
老师你好,这个代码要写哪里,我的二维码会增加行的时候自动生成输入,谢谢 此主题相关图片如下:1713071210443.png |
-- 作者:有点蓝 -- 发布时间:2024/4/14 20:43:00 -- 如果新增一行就马上生成,到datarowadded事件处理。如果是录入其它列的数据比如ID、类别后再生成,到datacolchanged事件处理 |
-- 作者:wlj88868 -- 发布时间:2024/4/15 20:29:00 -- datarowadded就是复制到这里了,,添加行还是没有数据,,,是不是还有加什么代码 上面的代码也是论坛上复制下来的,不会改,,麻烦老师给看看 |
-- 作者:有点蓝 -- 发布时间:2024/4/15 21:07:00 -- 先看看:http://www.foxtable.com/webhelp/topics/0625.htm、http://www.foxtable.com/webhelp/topics/1452.htm Select Case e.DataCol.Name Case "ID","类别" Dim dr As DataRow = e.DataRow If dr.IsNull("ID") OrElse dr.IsNull("类别") Then dr("二维码") = Nothing Else Dim n As Integer = 14 \'要生成密码长度 Dim str() As String = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S" , "T", "U", "V", "W", "X", "Y", "Z"} For i As Integer = 1 To str.Length \'洗牌测次数 Dim n1 As Integer = Rand.Next(str.Length) Dim n2 As Integer = Rand.Next(str.Length) Dim temp As String = str(n1) str(n1) = str(n2) str(n2) = temp Next Dim s As String = String.Join("", str) If n > s.Length Then n = s.Length End If dr("二维码") = s.Substring(0, n)End If End Select 如果完全看不懂代码,建议还是话时间学学基础
|