以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助]未将对象引用设置到对象的实例  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=137074)

--  作者:YDS
--  发布时间:2019/6/27 16:26:00
--  [求助]未将对象引用设置到对象的实例
.NET Framework 版本:4.0.30319.42000
Foxtable 版本:2019.6.18.1
错误所在事件:计划tcu
详细错误信息:
未将对象引用设置到对象的实例。

计划tcu代码
Static js As Integer
If vars("comt") > "" Then
    If Ports.Contains(vars("comt")) Then
        If Ports(vars("comt")).IsOpen Then
            If Forms("主窗口").Opened Then
                Dim xy As Integer
                If js > 11 Or js < 3 Then
                    js = 3
                Else
                    js = js + 1
                End If
                xy = js + 112
                Dim fssj As String =  "1-112-" & js & "-" & xy & "-2"
                If vars("logt") > "" Then
                    Filesys.WriteAllText(vars("logt"),Format(Date.now,"HH:mm:ss:fff") & "|" & js & "|" & fssj & vbcrlf, True)
                End If
                vars("cjs") = js
                vars("jssj") = Nothing
                Dim Val() As Byte = New Byte() {1,112,js,xy,2}
                Ports(vars("comt")).Write(Val, 0, Val.Length)
            End If
        End If
    End If
End If

--  作者:YDS
--  发布时间:2019/6/27 16:27:00
--  
执行间隔100ms
--  作者:YDS
--  发布时间:2019/6/27 16:29:00
--  
\'DataReceived事件代码
Dim i,cnt As Integer
Dim jssj As String
Select Case e.Port.PortName
    Case vars("com")
        cnt = e.Port.BytesToRead
        If cnt = 10 Then
            Dim Val(cnt - 1) As Byte
            e.Port.Read(Val,0,cnt)
            jssj = ""
            For i = 0 To cnt - 1
                If jssj = "" Then
                    jssj = Val(i)
                Else
                    jssj = jssj & "-" & Val(i)
                End If
            Next
            Functions.AsyncExecute("com",jssj)
        End If
    Case vars("comt")
        cnt = e.Port.BytesToRead
        If cnt > 0 Then
            Dim Val(cnt - 1) As Byte
            e.Port.Read(Val,0,cnt)
            jssj = ""
            For i = 0 To cnt - 1
                If jssj = "" Then
                    jssj = Val(i)
                Else
                    jssj = jssj & "-" & Val(i)
                End If
            Next
            Functions.AsyncExecute("comt",jssj)
        End If
End Select

--  作者:有点甜
--  发布时间:2019/6/27 18:50:00
--  

 

请加入msgbox或者output.show定位出错位置