以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  代码出错提示(编译错误:应为语句结束)  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=73031)

--  作者:阿福
--  发布时间:2015/8/11 11:55:00
--  代码出错提示(编译错误:应为语句结束)
Dim rl31 As Integer = Tables("肉猪新增窗口表").Rows(0)(1)
Dim rq As new List(of Date)
For i As Integer = 30 To 50
rq.add(Date.Today.AddDays(-i))
Next
Dim shang As Integer = rl31 \\ 20
Dim yu As Integer = rl31 Mod 20
Dim a1 As Integer = shang + 1
Dim a2 As Integer = shang 
Dim gs As new List(of Integer)
For i As Integer = 0 To yu
gs.Add(a1)
Next
For i As Integer = yu + 1 To 20
gs.add(a2)
Next

For i As Integer = 1 To 20
Dim drs As new List(of DataRow) = DataTables("肉猪信息").AddNew(gs(i))
For n As Integer = 0 To gs(i) - 1
drs(n)("编号") = Format(rq(i),"yyyyMMdd") & Format(n+1,"000")
Next
Next

蓝色背景的代码不知哪里出错了,提示
编译错误:应为语句结束
错误代码:Dim drs As new List(of DataRow) = DataTables("肉猪信息").AddNew(gs(i))

请老师帮我看一下,该怎么改?




--  作者:大红袍
--  发布时间:2015/8/11 11:58:00
--  

没有你那种语法

 

For i As Integer = 1 To 20
    For n As Integer = 0 To gs(i) - 1
        Dim ndr As DataRow = DataTables("肉猪信息").AddNew()
        ndr("编号") = Format(rq(i),"yyyyMMdd") & Format(n+1,"000")
    Next
Next


--  作者:阿福
--  发布时间:2015/8/11 12:06:00
--  
谢谢大红袍老师,还有个疑问,这里的”ndr“ 中的”n“指的是什么?是不是第n行?
--  作者:大红袍
--  发布时间:2015/8/11 12:15:00
--  

只是一个名称,你换成什么名字都可以。