此主题相关图片如下:用if 还是 case 或其他,怎样简化这样的选择?.jpg
If
e.Row("A") = True
andalso
e.Row("B") = False
andalso
e.Row("C") = False
andalso
e.Row("D") = False
andalso
e.Row("E") = False
andalso
e.Row("F") = False Then
Forms("窗口").open()
Forms("窗口").Controls("textboxA").Enabled = True
Forms("窗口").Controls("textboxB").Enabled = False
Forms("窗口").Controls("textboxC").Enabled = False
Forms("窗口").Controls("textboxD").Enabled = False
Forms("窗口").Controls("textboxE").Enabled = False
Forms("窗口").Controls("textboxF").Enabled = False
Elseif e.Row("A") = True
andalso
e.Row("B") = True andalso
e.Row("C") = False
andalso
e.Row("D") = False andalso e.Row("E") = False andalso e.Row("F") = False Then Forms("窗口").open()
Forms("窗口").Controls("textboxA").Enabled = True
Forms("窗口").Controls("textboxB").Enabled = True
Forms("窗口").Controls("textboxC").Enabled = False
Forms("窗口").Controls("textboxD").Enabled = False
Forms("窗口").Controls("textboxE").Enabled = False
Forms("窗口").Controls("textboxF").Enabled = False
Eseif e.Row("A") = True
andalso
e.Row("B") = True
andalso
e.Row("C") = True
andalso
e.Row("D") = False
andalso
e.Row("E") = False
andalso
e.Row("F") = False Then Forms("窗口").open()
Forms("窗口").Controls("textboxA").Enabled = True
Forms("窗口").Controls("textboxB").Enabled = True
Forms("窗口").Controls("textboxC").Enabled = True
Forms("窗口").Controls("textboxD").Enabled = False
Forms("窗口").Controls("textboxE").Enabled = False
Forms("窗口").Controls("textboxF").Enabled = False
.........
排列组合有720个啊,谁能简化这个代码吗???????
..........
.........
End If
应2、3楼要求补上执行代码!~
[此贴子已经被作者于2009-4-3 23:53:56编辑过]
应该能简化,只是像您贴代码,大家不好下手!
[此贴子已经被作者于2009-4-3 23:35:05编辑过]
......执行1
Forms("窗口").open()
Forms("窗口").Controls("textboxA").Enabled = True
Forms("窗口").Controls("textboxB").Enabled = False
Forms("窗口").Controls("textboxC").Enabled = False
Forms("窗口").Controls("textboxD").Enabled = False
Forms("窗口").Controls("textboxE").Enabled = False
Forms("窗口").Controls("textboxF").Enabled = False
......执行2:
Forms("窗口").open()
Forms("窗口").Controls("textboxA").Enabled = True
Forms("窗口").Controls("textboxB").Enabled = True
Forms("窗口").Controls("textboxC").Enabled = False
Forms("窗口").Controls("textboxD").Enabled = False
Forms("窗口").Controls("textboxE").Enabled = False
Forms("窗口").Controls("textboxF").Enabled = False
...............
这样能下手吗?????
[此贴子已经被作者于2009-4-3 23:47:25编辑过]
按钮代码:Forms("窗口").open()
要打开的窗口AfterLoad事件代码。
Dim r As Row = CurrentTable.Current
e.Form.Controls("textboxA").Enabled = r("A")
e.Form.Controls("textboxB").Enabled = r("B")
e.Form.Controls("textboxC").Enabled = r("C")
e.Form.Controls("textboxD").Enabled = r("D")
e.Form.Controls("textboxE").Enabled = r("E")
e.Form.Controls("textboxF").Enabled = r("F")
水平差就是不行,我这个才是正确的:
Dim r As Row = CurrentTable.Current
Dim Multi As String = "A|B|C|D|E|F"
Dim Values() as String
Values = Multi.split("|")
Forms("窗口").open()
For Index As Integer = 0 To Values.Length - 1
Forms("窗口").Controls("TextBox" & Values(Index)).Enabled = r(Values(Index))
Next
[此贴子已经被作者于2009-4-4 1:09:48编辑过]
我只是对象这样有规则的代码不会简化,版主可以做个放在‘命令窗口’中能执行即可,多谢啊~