以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- [求助]代码太长,看能不能简化? (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=11563) |
-- 作者:yanzhen2010 -- 发布时间:2011/8/3 10:13:00 -- [求助]代码太长,看能不能简化? If e.form.Controls("ComboBox1").Value Is Nothing Then
说明:主要是对"开嘱日期"、"医生"进行判断: 1、"开嘱日期"等于 "空 "、"医生"不等于 "空 " 则 2、"开嘱日期"等于 "空 "、"医生"等于 "空 ",则 1、"开嘱日期"不等于"空 "、"医生"等于 "空 " 则 2、"开嘱日期"不等于 "空 "、"医生"不等于 "空 ",则 判断条件太多,能不能简化? 因为我还存在一个三联式判断,那就更复杂了。
[此贴子已经被作者于2011-8-3 10:27:25编辑过]
|
-- 作者:狐狸爸爸 -- 发布时间:2011/8/3 10:20:00 -- If e.form.Controls("ComboBox1").Value Is Nothing Then MsgBox("请选择患者住院号!",64,"提示") Return End If Dim r As Row = CurrentTable.AddNew If e.Form.Controls("DateTimePicker1").Value Is Nothing And e.Form.Controls("ComboBox5").Value IsNot Nothing Then r("住院号") =e.Form.Controls("ComboBox1").value.split(":")(2) r("开嘱日期") =Date.Today r("医生") =e.Form.Controls("ComboBox5").value.split(":")(1) End If If e.Form.Controls("DateTimePicker1").Value Is Nothing And e.Form.Controls("ComboBox5").Value Is Nothing Then r("住院号") =e.Form.Controls("ComboBox1").value.split(":")(2) r("开嘱日期") =Date.Today End If If e.Form.Controls("DateTimePicker1").Value IsNot Nothing And e.Form.Controls("ComboBox5").Value Is Nothing Then r("住院号") =e.Form.Controls("ComboBox1").value.split(":")(2) r("开嘱日期") =e.Form.Controls("DateTimePicker1").value End If If e.Form.Controls("DateTimePicker1").Value IsNot Nothing And e.Form.Controls("ComboBox5").Value IsNot Nothing Then r("住院号") =e.Form.Controls("ComboBox1").value.split(":")(2) r("开嘱日期") =e.Form.Controls("DateTimePicker1").value r("医生") =e.Form.Controls("ComboBox5").value.split(":")(1) End If |
-- 作者:yanzhen2010 -- 发布时间:2011/8/3 10:31:00 -- 老总真快啊,太谢谢了。简化只能到此吗?那我后面的一个代码就更长了,需要8-9个IF. |
-- 作者:狐狸爸爸 -- 发布时间:2011/8/3 10:36:00 -- If e.form.Controls("ComboBox1").Value Is Nothing Then MsgBox("请选择患者住院号!",64,"提示") Return End If Dim r As Row = CurrentTable.AddNew r("住院号") =e.Form.Controls("ComboBox1").value.split(":")(2) If e.Form.Controls("DateTimePicker1").Value Is Nothing Then r("开嘱日期") =Date.Today Else r("开嘱日期") =e.Form.Controls("DateTimePicker1").value End If If e.Form.Controls("ComboBox5").Value IsNot Nothing Then r("医生") =e.Form.Controls("ComboBox5").value.split(":")(1) End If |