以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- [求助]怎么又出现运行报错? (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=58227) |
-- 作者:lpedu_jks -- 发布时间:2014/10/14 10:16:00 -- [求助]怎么又出现运行报错? 此主题相关图片如下:运行错误.jpg 我在统计“目标任务”时,怎么又出现运行错误“未将对象引用设置到对象的实例”?请指教。谢谢! [此贴子已经被作者于2014-10-14 10:16:56编辑过]
|
-- 作者:Bin -- 发布时间:2014/10/14 10:18:00 -- 点击显示详细信息,看看是那个事件报错,再把对应事件的代码发出来 |
-- 作者:lpedu_jks -- 发布时间:2014/10/14 10:20:00 -- .NET Framework 版本:2.0.50727.3655 Foxtable 版本:2014.9.23.1 错误所在事件:窗口,窗口1,目标任务,Click 详细错误信息: 未将对象引用设置到对象的实例。
|
-- 作者:Bin -- 发布时间:2014/10/14 10:22:00 -- 请看2楼 |
-- 作者:lpedu_jks -- 发布时间:2014/10/14 10:25:00 -- Dim Values() As String = {"总分"} Dim s1() As String = New String() {"总分"} Dim dt As Table = Tables("成绩库") StatusBar.Message1= "正在生成统计数据" Dim Time,Time1 As Date Time = Date.now e.Form.Controls("Label1").Text = "正在进行统计,请稍后……" e.Form.Controls("Label4").Text = "正在计时…" Functions.Execute("筛选记录",dt) Functions.Execute("总分排名",s1,dt) Functions.Execute("语数外排名",s1,dt) For Each tjnj As String In DataTables("校名设置").GetValues("统计年级","单位 = \'统计\'") For Each Value As String In Values Dim dtb As New DataTableBuilder( value & tjnj & "级目标") dtb.AddDef("部别",Gettype(String),8) dtb.AddDef("年级",Gettype(Double)) dtb.AddDef("单位",Gettype(String),8) dtb.AddDef("单位代码",Gettype(String),5) dtb.AddDef("目标1",Gettype(Double),"","重点_A级_目标") dtb.AddDef("目标2",Gettype(Double),"","重点_A级_完成") dtb.AddDef("目标3",Gettype(Double),"","重点_B级_目标") dtb.AddDef("目标4",Gettype(Double),"","重点_B级_完成") dtb.AddDef("目标9",Gettype(Double),"","重点_C级_目标") dtb.AddDef("目标10",Gettype(Double),"","重点_C级_完成") dtb.AddDef("目标5",Gettype(Double),"","本科以上_目标") dtb.AddDef("目标6",Gettype(Double),"","本科以上_完成") dtb.AddDef("目标7",Gettype(Double),"","专科以上(语数外)_目标") dtb.AddDef("目标8",Gettype(Double),"","专科以上(语数外)_完成") dtb.Build() Tables( value & tjnj & "级目标").SetHeaderRowHeight(26,26,26) \'表名的标题行的行高 Tables( value & tjnj & "级目标").DefaultRowHeight = 25 \'设置默认的行高 Tables( value & tjnj & "级目标").SetColVisibleWidth("单位|70|部别|50|年级|50|单位代码|44|目标1|50|目标2|50|目标3|50|目标4|50|目标9|50|目标10|50|目标5|50|目标6|50|目标7|53|目标8|53") Tables( value & tjnj & "级目标").Cols("部别").TextAlign = TextAlignEnum.Center Tables( value & tjnj & "级目标").Cols("年级").TextAlign = TextAlignEnum.Center Tables( value & tjnj & "级目标").Cols("单位").TextAlign = TextAlignEnum.Center Tables( value & tjnj & "级目标").Cols("单位代码").TextAlign = TextAlignEnum.Center Next For Each bubie As String In DataTables("成绩库").GetValues("部别","年级 = \'" & tjnj & "\'") For Each bm As DataTable In DataTables If bm.name <> "成绩库" AndAlso bm.Name <> "校名设置" AndAlso bm.Name <> "目标设置" AndAlso bm.Name <> "名册" AndAlso bm.Name <> "信息表" AndAlso bm.Name <> "原始名册" Dim dr As DataRow dr = DataTables(bm.name).addnew() dr("单位") = "全县合计" dr("部别") = bubie dr("年级") = tjnj Dim jdr As DataRow = DataTables("目标设置").Find("部别 = \'" & dr("部别") & "\' And 年级 = \'" & dr("年级") & "\' And 类别 = \'县合计\'") Dim c1 As Double = jdr("目标9") Dim c2 As Double = jdr("目标10") Dim c9 As Double = jdr("目标8") Dim c3 As Double = jdr("目标12") Dim c4 As Double = jdr("目标13") Dim tj As String = Left(bm.name,2) & "排名" Dim tj1 As String = Left(bm.name,2) tj1 = Left(bm.name,2) Dim c5 As Double = DataTables("成绩库").Find(" " & tj & " = \'" & c1 & "\' And [部别] = \'" & dr("部别") & "\' And 年级 = \'" & dr("年级") & "\'")(tj1) Dim c6 As Double = DataTables("成绩库").Find(" " & tj & " = \'" & c2 & "\' And [部别] = \'" & dr("部别") & "\' And 年级 = \'" & dr("年级") & "\'")(tj1) Dim c10 As Double = DataTables("成绩库").Find(" " & tj & " = \'" & c9 & "\' And [部别] = \'" & dr("部别") & "\' And 年级 = \'" & dr("年级") & "\'")(tj1) Dim c7 As Double = DataTables("成绩库").Find(" " & tj & " = \'" & c3 & "\' And [部别] = \'" & dr("部别") & "\' And 年级 = \'" & dr("年级") & "\'")(tj1) Dim c8 As Double = DataTables("成绩库").Find(" " & tj & " = \'" & c4 & "\' And [部别] = \'" & dr("部别") & "\' And 年级 = \'" & dr("年级") & "\'")(tj1) dr("目标1") = c1 dr("目标3") = c2 dr("目标9") = c9 dr("目标5") = c3 dr("目标7") = c4 dr("目标2") = DataTables("成绩库").Compute("count(单位)", " " & tj1 & " >= \'" & c5 & "\' And [部别] = \'" & dr("部别") & "\' And 年级 = \'" & dr("年级") & "\'") dr("目标4") = DataTables("成绩库").Compute("count(单位)", " " & tj1 & " >= \'" & c6 & "\' And [部别] = \'" & dr("部别") & "\' And 年级 = \'" & dr("年级") & "\'") dr("目标10") = DataTables("成绩库").Compute("count(单位)", " " & tj1 & " >= \'" & c10 & "\' And [部别] = \'" & dr("部别") & "\' And 年级 = \'" & dr("年级") & "\'") dr("目标6") = DataTables("成绩库").Compute("count(单位)", " " & tj1 & " >= \'" & c7 & "\' And [部别] = \'" & dr("部别") & "\' And 年级 = \'" & dr("年级") & "\'") dr("目标8") = DataTables("成绩库").Compute("count(单位)", "语数外排名 <= \'" & c4 & "\' And [部别] = \'" & dr("部别") & "\' And 年级 = \'" & dr("年级") & "\'") End If Next Next StatusBar.Refresh StatusBar.Reset StatusBar.DefaultMessage = "统计完毕!" e.Form.Controls("Label1").text ="统计结束,请导出数据!否则数据会丢失!" Time1 = Date.Now e.Form.Controls("Label4").text="耗时 " & (Time1-Time).TotalSeconds & " 秒" DataTables("成绩库").ResumeRedraw
|
-- 作者:Bin -- 发布时间:2014/10/14 10:29:00 -- 代码太长,可能出现问题的地方太多,而且你还有几个内部函数,也有可能出现问题的地方是内部函数. 类似Dim c5 As Double = DataTables("成绩库").Find(" " & tj & " = \'" & c1 & "\' And [部别] = \'" & dr("部别") & "\' And 年级 = \'" & dr("年级") & "\'")(tj1) 这些代码,不要这样直接取值,万一行没找到呢,不就报空值错误了吗? Dim jdr As DataRow = DataTables("目标设置").Find("部别 = \'" & dr("部别") & "\' And 年级 = \'" & dr("年级") & "\' And 类别 = \'县合计\'") 先这些也要判断一下是否空行再去取值 if jdr isnot nothing then Dim c1 As Double = jdr("目标9") Dim c2 As Double = jdr("目标10") Dim c9 As Double = jdr("目标8") Dim c3 As Double = jdr("目标12") Dim c4 As Double = jdr("目标13") end if 建议您用这个方法: http://www.foxtable.com/help/topics/1485.htm 先找出是哪一行出错,然后分析原因,搞不定,跟帖诉我们运行到哪一行出错。 |
-- 作者:有点甜 -- 发布时间:2014/10/14 10:38:00 -- 请先自行调试,确认哪里出错。http://www.foxtable.com/help/topics/1485.htm
不行,就上传例子 |
-- 作者:lpedu_jks -- 发布时间:2014/10/14 11:10:00 -- 先传了2次,怎么没传上去。 |
-- 作者:lpedu_jks -- 发布时间:2014/10/14 11:13:00 -- 还是没传上去。 |
-- 作者:有点甜 -- 发布时间:2014/10/14 11:16:00 -- 你看7楼,先自己定位一下错误啊。 |