以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  老爹看下这个代码怎么写?(已解决)  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=10934)

--  作者:YDS
--  发布时间:2011/6/30 15:06:00
--  老爹看下这个代码怎么写?(已解决)

一个录入窗口

 


此主题相关图片如下:01.jpg
按此在新窗口浏览图片

 

原来这个录入窗口一次录入一个人,代码已经编写了,现在想实现同时多人录入,老爹有什么办法简化代码不?

 

我现在的写法是

If e.Form.controls("A").checked = True
Dim lqry As String = "A"
Dim lqsl As Integer = e.Form.Controls("sl1").Value

原录入代码

If e.Form.controls("B").checked = True
Dim lqry As String = "B"
Dim lqsl As Integer = e.Form.Controls("sl2").Value

原录入代码

If e.Form.controls("C").checked = True
Dim lqry As String = "C"
Dim lqsl As Integer = e.Form.Controls("sl3").Value

原录入代码

If e.Form.controls("D").checked = True
Dim lqry As String = "D"
Dim lqsl As Integer = e.Form.Controls("sl4").Value

原录入代码

感觉这样写出来代码很繁琐,以上代码是否可以简写,谢谢!



 

[此贴子已经被作者于2011-6-30 16:30:16编辑过]

--  作者:狐狸爸爸
--  发布时间:2011/6/30 15:24:00
--  

大概就是如此,就是100个也是这样的代码:

 

Dim nms1() as string = {"A","B","C","D"}

Dim nms2() as string = {"sl1","sl2","sl3","sl4"}

For i as integer = 0 to nms.length -1

    If e.Form.controls(nms1(i)).checked = True

         Dim lqry As String = nms1(i)

          Dim lqsl As Integer = e.Form.Controls(nms(2)).Value

    end if

next

 


--  作者:YDS
--  发布时间:2011/6/30 16:01:00
--  
以下是引用狐狸爸爸在2011-6-30 15:24:00的发言:

大概就是如此,就是100个也是这样的代码:

 

Dim nms1() as string = {"A","B","C","D"}

Dim nms2() as string = {"sl1","sl2","sl3","sl4"}

For i as integer = 0 to nms.length -1

    If e.Form.controls(nms1(i)).checked = True

         Dim lqry As String = nms1(i)

          Dim lqsl As Integer = e.Form.Controls(nms(2)).Value

    end if

next

 

错误代码:name \'lqsl\' is not declared

--  作者:狐狸爸爸
--  发布时间:2011/6/30 16:04:00
--  

Dim nms1() As String = {"A","B","C","D"}
Dim nms2() as string = {"sl1","sl2","sl3","sl4"}
For i As Integer = 0 To nms.length -1
    If e.Form.controls(nms1(i)).checked = True
        Dim lqry As String = nms1(i)
        Dim lqsl As Integer = e.Form.Controls(nms(2)).Value
        \'原来的代码
    End If
next


--  作者:YDS
--  发布时间:2011/6/30 16:29:00
--  
以下是引用狐狸爸爸在2011-6-30 16:04:00的发言:

Dim nms1() As String = {"A","B","C","D"}
Dim nms2() as string = {"sl1","sl2","sl3","sl4"}
For i As Integer = 0 To nms.length -1
    If e.Form.controls(nms1(i)).checked = True
        Dim lqry As String = nms1(i)
        Dim lqsl As Integer = e.Form.Controls(nms(2)).Value
        \'原来的代码
    End If
next

是我大意了,谢谢狐爸!