以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 控件不为空 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=158952) |
-- 作者:良才 -- 发布时间:2020/12/8 11:32:00 -- 控件不为空 请指教代码,谢谢! For Each c As object In e.Form.Controls If e.Sender.Name.StartsWith("Xm") OrElse e.Sender.Name.StartsWith("Sj") OrElse e.Sender.Name.StartsWith("Pf") Then Dim kjmc() As String = ? For i As Integer = 0 To kjmc.Length - 1 If e.Form.Controls(kjmc(i)).text = Nothing Then MessageBox.Show("不能为空,请检查") e.Form.Controls(kjmc(i)).Select Return End If Next End If Next
[此贴子已经被作者于2020/12/8 11:57:44编辑过]
|
-- 作者:有点蓝 -- 发布时间:2020/12/8 12:03:00 -- Dim kjmc() As String ={“Xm”,“Sj”,“Pf”} For Each c As object In e.Form.Controls If e.Sender.Name.StartsWith("Xm") OrElse e.Sender.Name.StartsWith("Sj") OrElse e.Sender.Name.StartsWith("Pf") Then For each s as string in kjmc For i As Integer = 1 To 10 If e.Form.Controls(s & i).text = "" Then MessageBox.Show("不能为空,请检查") e.Form.Controls(s & i).Select Return End If Next Next End If Next
|
-- 作者:良才 -- 发布时间:2020/12/8 12:33:00 -- 谢谢 |
-- 作者:良才 -- 发布时间:2020/12/8 15:25:00 -- 老师没有效果 |
-- 作者:良才 -- 发布时间:2020/12/8 15:46:00 -- 老师搞定了 Dim kjmc() As String ={"Xm","Sj","Pf"} For Each c As object In e.Form.Controls If c.Name.StartsWith("Xm") OrElse c.Name.StartsWith("Sj") OrElse c.Name.StartsWith("Pf") Then For Each s As String In kjmc For i As Integer = 1 To 10 If e.Form.Controls(s & i).text = Nothing Then MessageBox.Show("不能为空,请检查") e.Form.Controls(s & i).Select Return End If Next Next End If Next [此贴子已经被作者于2020/12/8 15:46:07编辑过]
|
-- 作者:良才 -- 发布时间:2020/12/9 12:12:00 -- 老师还想请教保存代码 这样教工工号可以输入,到岗时间不行。 Dim n As Integer For Each c As object In e.Form.Controls If c.Name.StartsWith("Xm") Then dr = DataTables("值日记载").AddNew() dr("值日日期") = e.form.Controls("值日日期").Text If c.Value IsNot Nothing Then Dim Tel As String = e.form.Controls("Xm" & n+1).Text Dim Parts() As String = Tel.Split("(") dr("教工工号") = Parts(1).Trim(")") n+=1 End If If c.Name.StartsWith("Sj") Then dr("到岗时间") = e.form.Controls("Sj" & n+1).Text n+=1 End If End If Next
|
-- 作者:有点蓝 -- 发布时间:2020/12/9 13:38:00 -- 提示什么错误? |
-- 作者:良才 -- 发布时间:2020/12/9 13:40:00 -- 没有提示错误,到岗时间列 是空的 [此贴子已经被作者于2020/12/9 13:49:04编辑过]
|
-- 作者:有点蓝 -- 发布时间:2020/12/9 13:50:00 -- Dim n As Integer For Each c As object In e.Form.Controls If c.Name.StartsWith("Xm") Then dr = DataTables("值日记载").AddNew() dr("值日日期") = e.form.Controls("值日日期").Text If c.Value IsNot Nothing Then Dim Tel As String = e.form.Controls("Xm" & n+1).Text Dim Parts() As String = Tel.Split("(") dr("教工工号") = Parts(1).Trim(")") n+=1 End If End If If c.Name.StartsWith("Sj") Then dr("到岗时间") = e.form.Controls("Sj" & n+1).Text n+=1 End If Next
|
-- 作者:良才 -- 发布时间:2020/12/9 14:32:00 -- 老师我做了例子 [此贴子已经被作者于2020/12/9 14:58:38编辑过]
|