以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  请问这怎么写  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=90996)

--  作者:刘林
--  发布时间: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怎么写?谢谢

 


--  作者:有点蓝
--  发布时间: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

--  作者:刘林
--  发布时间: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类似的班号,请指点,谢谢。


--  作者:有点蓝
--  发布时间:2016/9/27 14:39:00
--  
dr2(Cols2(i)) = s1(1).PadLeft(2,"0")


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