Foxtable(狐表)用户栏目专家坐堂 → 老爹看下这个代码怎么写?(已解决)


  共有10851人关注过本帖树形打印复制链接

主题:老爹看下这个代码怎么写?(已解决)

帅哥哟,离线,有人找我吗?
YDS
  1楼 | QQ | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:三尾狐 帖子:632 积分:3619 威望:0 精华:0 注册:2011/5/21 18:05:00
老爹看下这个代码怎么写?(已解决)  发帖心情 Post By: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编辑过]

 回到顶部
帅哥哟,离线,有人找我吗?
狐狸爸爸
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:管理员 帖子:47497 积分:251403 威望:0 精华:91 注册:2008/6/17 17:14:00
  发帖心情 Post By: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
  3楼 | QQ | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:三尾狐 帖子:632 积分:3619 威望:0 精华:0 注册:2011/5/21 18:05:00
  发帖心情 Post By: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

 回到顶部
帅哥哟,离线,有人找我吗?
狐狸爸爸
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:管理员 帖子:47497 积分:251403 威望:0 精华:91 注册:2008/6/17 17:14:00
  发帖心情 Post By: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
  5楼 | QQ | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:三尾狐 帖子:632 积分:3619 威望:0 精华:0 注册:2011/5/21 18:05:00
  发帖心情 Post By: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

是我大意了,谢谢狐爸!


 回到顶部