标题:过程太大怎么拆分(附部分代码)
只看楼主
w53521
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2008-12-8
 问题点数:0 回复次数:2 
过程太大怎么拆分(附部分代码)
Case 511 To 512
        If recshap.Fields("id").ValueAsString = "1" Then
          Load frmquery
          frmquery.Image2.Picture = LoadPicture("D:\延安空间信息系统数据\柱状图\硝酸盐\YH01.jpg")
          frmquery.Show
                  ElseIf recshap.Fields("id").ValueAsString = "2" Then
          Load frmquery
          frmquery.Image2.Picture = LoadPicture("D:\延安空间信息系统数据\柱状图\硝酸盐\YH02.jpg")
          frmquery.Show
                            ElseIf recshap.Fields("id").ValueAsString = "3" Then
          Load frmquery
          frmquery.Image2.Picture = LoadPicture("D:\延安空间信息系统数据\柱状图\硝酸盐\YH03.jpg")
          frmquery.Show
                          ElseIf recshap.Fields("id").ValueAsString = "4" Then
          Load frmquery
          frmquery.Image2.Picture = LoadPicture("D:\延安空间信息系统数据\柱状图\硝酸盐\YH04.jpg")
          frmquery.Show
                          ElseIf recshap.Fields("id").ValueAsString = "5" Then
          Load frmquery
          frmquery.Image2.Picture = LoadPicture("D:\延安空间信息系统数据\柱状图\硝酸盐\YH05.jpg")
          frmquery.Show
                           ElseIf recshap.Fields("id").ValueAsString = "6" Then
          Load frmquery
          frmquery.Image2.Picture = LoadPicture("D:\延安空间信息系统数据\柱状图\硝酸盐\YH06.jpg")
          frmquery.Show
                            ElseIf recshap.Fields("id").ValueAsString = "7" Then
          Load frmquery
          frmquery.Image2.Picture = LoadPicture("D:\延安空间信息系统数据\柱状图\硝酸盐\YH07.jpg")
          frmquery.Show
                           ElseIf recshap.Fields("id").ValueAsString = "8" Then
          Load frmquery
          frmquery.Image2.Picture = LoadPicture("D:\延安空间信息系统数据\柱状图\硝酸盐\YH08.jpg")
          frmquery.Show
                            ElseIf recshap.Fields("id").ValueAsString = "9" Then
          Load frmquery
          frmquery.Image2.Picture = LoadPicture("D:\延安空间信息系统数据\柱状图\硝酸盐\YH09.jpg")
          frmquery.Show
                            ElseIf recshap.Fields("id").ValueAsString = "10" Then
          Load frmquery
          frmquery.Image2.Picture = LoadPicture("D:\延安空间信息系统数据\柱状图\硝酸盐\YH10.jpg")
          frmquery.Show
                            ElseIf recshap.Fields("id").ValueAsString = "11" Then
          Load frmquery
          frmquery.Image2.Picture = LoadPicture("D:\延安空间信息系统数据\柱状图\硝酸盐\YH11.jpg")
          frmquery.Show
                            ElseIf recshap.Fields("id").ValueAsString = "12" Then
          Load frmquery
          frmquery.Image2.Picture = LoadPicture("D:\延安空间信息系统数据\柱状图\硝酸盐\YH12.jpg")
          frmquery.Show
                            ElseIf recshap.Fields("id").ValueAsString = "13" Then
          Load frmquery
          frmquery.Image2.Picture = LoadPicture("D:\延安空间信息系统数据\柱状图\硝酸盐\YH13.jpg")
          frmquery.Show
                            ElseIf recshap.Fields("id").ValueAsString = "14" Then
          Load frmquery
          frmquery.Image2.Picture = LoadPicture("D:\延安空间信息系统数据\柱状图\硝酸盐\YH14.jpg")
          frmquery.Show
                            ElseIf recshap.Fields("id").ValueAsString = "15" Then
          Load frmquery
          frmquery.Image2.Picture = LoadPicture("D:\延安空间信息系统数据\柱状图\硝酸盐\YH15.jpg")
          frmquery.Show
                        ElseIf recshap.Fields("id").ValueAsString = "16" Then
          Load frmquery
          frmquery.Image2.Picture = LoadPicture("D:\延安空间信息系统数据\柱状图\硝酸盐\YH16.jpg")
          frmquery.Show
                         ElseIf recshap.Fields("id").ValueAsString = "17" Then
          Load frmquery
          frmquery.Image2.Picture = LoadPicture("D:\延安空间信息系统数据\柱状图\硝酸盐\YH17.jpg")
          frmquery.Show
                            ElseIf recshap.Fields("id").ValueAsString = "18" Then
          Load frmquery
          frmquery.Image2.Picture = LoadPicture("D:\延安空间信息系统数据\柱状图\硝酸盐\YH18.jpg")
          frmquery.Show
                         ElseIf recshap.Fields("id").ValueAsString = "19" Then
          Load frmquery
          frmquery.Image2.Picture = LoadPicture("D:\延安空间信息系统数据\柱状图\硝酸盐\YH19.jpg")
          frmquery.Show
                            ElseIf recshap.Fields("id").ValueAsString = "20" Then
          Load frmquery
          frmquery.Image2.Picture = LoadPicture("D:\延安空间信息系统数据\柱状图\硝酸盐\YH20.jpg")
          frmquery.Show
                            ElseIf recshap.Fields("id").ValueAsString = "21" Then
          Load frmquery
          frmquery.Image2.Picture = LoadPicture("D:\延安空间信息系统数据\柱状图\硝酸盐\YH21.jpg")
                   Load frmquery
                  ElseIf recshap.Fields("id").ValueAsString = "22" Then
          Load frmquery
          frmquery.Image2.Picture = LoadPicture("D:\延安空间信息系统数据\柱状图\硝酸盐\YH22.jpg")
          frmquery.Show
                           ElseIf recshap.Fields("id").ValueAsString = "23" Then
          Load frmquery
          frmquery.Image2.Picture = LoadPicture("D:\延安空间信息系统数据\柱状图\硝酸盐\YH23.jpg")
          frmquery.Show
                            ElseIf recshap.Fields("id").ValueAsString = "24" Then
          Load frmquery
          frmquery.Image2.Picture = LoadPicture("D:\延安空间信息系统数据\柱状图\硝酸盐\YH24.jpg")
          frmquery.Show
                            ElseIf recshap.Fields("id").ValueAsString = "25" Then
          Load frmquery
          frmquery.Image2.Picture = LoadPicture("D:\延安空间信息系统数据\柱状图\硝酸盐\YH25.jpg")
          frmquery.Show
                            ElseIf recshap.Fields("id").ValueAsString = "26" Then
          Load frmquery
          frmquery.Image2.Picture = LoadPicture("D:\延安空间信息系统数据\柱状图\硝酸盐\YH26.jpg")
          frmquery.Show
                            ElseIf recshap.Fields("id").ValueAsString = "27" Then
          Load frmquery
          frmquery.Image2.Picture = LoadPicture("D:\延安空间信息系统数据\柱状图\硝酸盐\YH27.jpg")
          frmquery.Show
                            ElseIf recshap.Fields("id").ValueAsString = "28" Then
          Load frmquery
          frmquery.Image2.Picture = LoadPicture("D:\延安空间信息系统数据\柱状图\硝酸盐\YH28.jpg")
          frmquery.Show
                            ElseIf recshap.Fields("id").ValueAsString = "29" Then
          Load frmquery
          frmquery.Image2.Picture = LoadPicture("D:\延安空间信息系统数据\柱状图\硝酸盐\YH29.jpg")
          frmquery.Show
                            ElseIf recshap.Fields("id").ValueAsString = "30" Then
          Load frmquery
          frmquery.Image2.Picture = LoadPicture("D:\延安空间信息系统数据\柱状图\硝酸盐\YH30.jpg")
          frmquery.Show
                    
          Else
         
          Load frmquery
          frmquery.Show
          frmquery.Refresh
                  
        End If
搜索更多相关主题的帖子: 拆分 代码 
2008-12-08 17:32
w53521
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2008-12-8
得分:0 
补充
都是和这些类似的case
每个case中有大约90多个if判断语句
2008-12-08 17:34
bygg
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:乖乖的心中
等 级:版主
威 望:241
帖 子:13555
专家分:3076
注 册:2006-10-23
得分:0 
Case 511 To 512
     Load frmquery
     frmquery.Image2.Picture = LoadPicture("D:\延安空间信息系统数据\柱状图\硝酸盐\YH" & recshap.Fields("id").ValueAsString & ".jpg")
     frmquery.Show
Case 513
     .....
 
------------
将recshap.Fields("id").ValueAsString做为图片名称中的参数..
如果可能出现图片不存在,加个try...catch...什么的处理一下就可以了

飘过~~
2008-12-08 17:48



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-248305-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.287102 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved