以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  [求助]加载树报错  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=96470)

--  作者:铜豆
--  发布时间:2017/2/21 15:59:00
--  [求助]加载树报错

NodeMouseClick:

Dim Filter As String

 Dim dr As DataRow = e.Node.DataRow 

Dim Year As Integer = dr("年")

Dim Month As Integer = dr("月")

Dim day As Integer  = dr("日")

If e.node.Text = "加载所有数据" Then

    Filter = ""

Else

    Select Case e.Node.Level

        Case 0

            Filter ="Year(日期) = " & Year

        Case 1

            Filter ="Year(日期) = " & Year & " And Month(日期) = " & Month

        Case 2

            Filter ="Year(日期) = " & Year & " And Month(日期) = " & Month & " And day(日期) = " & day

    End Select

End If

DataTables("订单组合1").LoadFilter = Filter

DataTables("订单组合1").Load()

在点击加载所有数据时报错

报错信息为:未将对象引用设置到对象的实例。


--  作者:有点色
--  发布时间:2017/2/21 16:47:00
--  

Dim dr As DataRow = e.Node.DataRow
Dim Year As Integer = dr("年")
Dim Month As Integer = dr("月")
Dim day As Integer  = dr("日")

 

改成-----------------------------------------

 

Dim dr As DataRow = e.Node.FullName.split("\\")
Dim Year As Integer = ary(0)
Dim Month As Integer = ary(1)
Dim day As Integer  = ary(2)

 


--  作者:铜豆
--  发布时间:2017/2/21 16:56:00
--  

图片点击可在新窗口打开查看此主题相关图片如下:zsl118zhq_1487667279462_85.png
图片点击可在新窗口打开查看

--  作者:有点色
--  发布时间:2017/2/21 18:10:00
--  

哦,改成

 

Dim ary() As String = e.Node.FullName.split("\\")
Dim Year As Integer = ary(0)
Dim Month As Integer = ary(1)
Dim day As Integer  = ary(2)

 


--  作者:铜豆
--  发布时间:2017/2/21 18:16:00
--  
从字符串“加载所有数据”到类型“Integer”的转换无效。
--  作者:有点色
--  发布时间:2017/2/21 18:24:00
--  

Dim Filter As String

If e.node.Text = "加载所有数据" Then
   
    Filter = ""
   
Else
   
    Dim ary() As String = e.Node.FullName.split("\\")
    Dim Year As Integer = ary(0)
    Dim Month As Integer = ary(1)
    Dim day As Integer  = ary(2)
   
    Select Case e.Node.Level
       
        Case 0
           
            Filter ="Year(日期) = " & Year
           
        Case 1
           
            Filter ="Year(日期) = " & Year & " And Month(日期) = " & Month
           
        Case 2
           
            Filter ="Year(日期) = " & Year & " And Month(日期) = " & Month & " And day(日期) = " & day
           
    End Select
   
End If

DataTables("订单组合1").LoadFilter = Filter


DataTables("订单组合1").Load()


--  作者:铜豆
--  发布时间:2017/2/21 18:42:00
--  
报错信息:索引超出了数组界限。

    Dim ary() As String = e.Node.FullName.split("\\")
    Dim Year As Integer = ary(0)
    Dim Month As Integer = ary(1)
    Dim day As Integer  = ary(2)
段代码没讲过老师是否可详解一下,怎么调用数组了