Rss & SiteMap

Foxtable(狐表) http://www.foxtable.com

新一代数据库软件,完美融合Access、Foxpro、Excel、vb.net之优势,人人都能掌握的快速软件开发工具!
共5 条记录, 每页显示 10 条, 页签: [1]
[浏览完整版]

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

1楼
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编辑过]
2楼
狐狸爸爸 发表于: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

 

3楼
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
4楼
狐狸爸爸 发表于: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

5楼
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

是我大意了,谢谢狐爸!

共5 条记录, 每页显示 10 条, 页签: [1]

Copyright © 2000 - 2018 foxtable.com Tel: 4000-810-820 粤ICP备11091905号

Powered By Dvbbs Version 8.3.0
Processed in .03516 s, 2 queries.