以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- [求助]后台查找数组对应的电话号,以数组集合形式填写到控件中,String.join (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=168897) |
-- 作者:myjht -- 发布时间:2021/5/26 11:41:00 -- [求助]后台查找数组对应的电话号,以数组集合形式填写到控件中,String.join 求助:窗口Validating代码 窗口DropBox1的值如:张三,李四,王二 后台数据库查找车组人员表,将张三电话,李四电话,王二电话填写到窗口TextBox4中,如:131123456789,132123456789,133123456789 求助代码如下: Dim dlm As String = e.Form.Controls("DropBox1").Text \'DropBox1的值如"张三,李四,王二" If dlm = "" Then Messagebox.Show("物流人员不能为空,请选择录入!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information) Return End If Dim sps() As Char = {",","|","/"} Dim nms() As String = dlm.Split(sps) \'将工号列内容拆分成数组 Dim drs As List(of String) Dim ls As new List(of String) For Each nm As String In nms drs = DataTables("车组人员表").SQLGetValues("联系电话","[姓名] = \'" & nm & "\'") \'drs = DataTables("车组人员表").SQLGetComboListString("联系电话","[姓名] = \'" & nm & "\'") MessageBox.Show(nm) Next For Each dr As String In drs ls.add(dr) \'Exit For \'ls.add(dr("联系电话")) \'\'ls.AddRange(dr("联系电话")) \'将数组中的元素全部加入到集合中 \'\'MessageBox.Show(ls.add(dr("联系电话"))) Next If drs.Count > 0 \'如果找到了符合条件的行 e.Form.Controls("TextBox4").Value = String.join("|",ls.ToArray()) \'TextBox4的值效果为"13123456789|132123456789|133123456789" \'MessageBox.Show(ls) Else Messagebox.Show("请选择车长所在的车组,如果物流人员车长变化,请先回来选择车组,再选择人员!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information) Return End If
|
-- 作者:有点蓝 -- 发布时间:2021/5/26 11:53:00 -- Dim dlm As String = e.Form.Controls("DropBox1").Text \'DropBox1的值如"张三,李四,王二" Dim sps() As Char = {",","|","/"} Dim nms() As String = dlm.Split(sps) e.Form.Controls("TextBox4").text = DataTables("车组人员表").SQLGetComboListString("联系电话","[姓名] in (\'" & string.join("\',\'",nms) & "\')")
|
-- 作者:myjht -- 发布时间:2021/5/26 12:42:00 -- 谢谢蓝版,天啊,我啰嗦了半篇子代码,您1句搞定了,太神了, |
-- 作者:zhutangxin -- 发布时间:2021/6/3 0:33:00 -- Mark, Split(数组) |