Foxtable(狐表)用户栏目专家坐堂 → 请问这怎么写


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

主题:请问这怎么写

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


加好友 发短信
等级:八尾狐 帖子:1953 积分:15015 威望:0 精华:0 注册:2016/4/28 9:58:00
请问这怎么写  发帖心情 Post By:2016/9/27 11:28:00 [只看该作者]

Dim Cols1() As String = {"学校名称","年级","班级","学生姓名","身份证件号"}
Dim Cols2() As String = {"单位名称","年级代码","班级","姓名","身份证件号"}
For Each dr1 As DataRow In DataTables("学生信息").DataRows
    Dim dr2 As DataRow = DataTables("成绩").AddNew()
   
    For i As Integer = 0 To Cols1.Length -1
        Select Case i
            Case 0
                dr2(Cols2(i)) = dr1(Cols1(i)).Substring(6,7)
            Case 1
                dr2(Cols2(i)) = dr1(Cols1(i)).Substring(4,2)
               
            Case 2
                                         
        End Select
       
    Next
Next

学生信息表中班级列格式:初中2015级1班,或初中2015级12班,班号有的大于10,成绩表中班级列格式:01或12,请问Case 2怎么写?谢谢

 


 回到顶部
帅哥,在线噢!
有点蓝
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:110744 积分:563646 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2016/9/27 11:40:00 [只看该作者]

Dim c() As Char = {"级", "班"}
Dim str As String = "2015级1班"
Dim s1() As String = str.Split(c)
For Each s As String In s1
    Output.Show(s)
Next

 回到顶部
帅哥哟,离线,有人找我吗?
刘林
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:八尾狐 帖子:1953 积分:15015 威望:0 精华:0 注册:2016/4/28 9:58:00
  发帖心情 Post By:2016/9/27 13:32:00 [只看该作者]

Dim Cols1() As String = {"学校名称","年级","班级","学生姓名","身份证件号"}
Dim Cols2() As String = {"单位名称","年级代码","班级","姓名","身份证件号"}
For Each dr1 As DataRow In DataTables("学生信息").DataRows
    Dim dr2 As DataRow = DataTables("成绩").AddNew()
    For i As Integer = 0 To Cols1.Length -1
        Select Case i
            Case 0
                dr2(Cols2(i)) = dr1(Cols1(i)).Substring(6,7)
            Case 1
                dr2(Cols2(i)) = dr1(Cols1(i)).Substring(4,2)           
            Case 2               
                Dim c() As Char = {"级", "班"}
                Dim str As String = dr1(Cols1(i))
                Dim s1() As String = str.Split(c)
                dr2(Cols2(i)) = format(s1(1),"00")
            Case 3,4
                dr2(Cols2(i)) = dr1(Cols1(i))    
        End Select
       
    Next
Next

 

 

请问老师,为什么红色代码填出来班级全为00呢?我是想填为01,02,11,12类似的班号,请指点,谢谢。


 回到顶部
帅哥,在线噢!
有点蓝
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:110744 积分:563646 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2016/9/27 14:39:00 [只看该作者]

dr2(Cols2(i)) = s1(1).PadLeft(2,"0")


不是什么场合都可以用format的

 回到顶部