求助:窗口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