evaporated 发表于 2006-2-26 11:54:00

[求助]vb.net 里这个错误是怎么回事啊?

<P>&nbsp;&nbsp; vb.net中的object reference not set to an instance of an object</P>
<P>错误,代码如下:</P>
<P>imports System.Runtime.InteropServices<BR>&nbsp;&nbsp; &lt;StructLayout(LayoutKind.sequential)&gt; structure PT_DioWriteBit<BR>&nbsp;&nbsp; ......<BR>&nbsp;&nbsp; end structure</P>
<P>&nbsp;&nbsp; private lpDioWritePort As PT_DioWritePortByte</P>
<P>&nbsp;&nbsp; Declare Function DRV_DioWriteBit Lib "adsapi32.dll"<BR>&nbsp;&nbsp; (ByVal DriverHandle As integer,byref DioWriteBit As PT_DioWriteBit) As<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; integer</P>
<P>&nbsp;&nbsp; Dim ptDioWriteBit As New PT_DioWriteBit<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ptDioWriteBit.Port = 0<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ptDioWriteBit.bit = 1<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ptDioWriteBit.state = 1</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim newClass1 As New class1<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; errCde = newClass1.DRV_DioWriteBit(deviceHandle, ptDioWriteBit)</P>
<P>errCde为整型</P>
<P>到这里调用函数DRV_DioWriteBit时,出现该错误。</P>
<P>&nbsp;object reference not set to an instance of an object</P>
<P>请教各位大虾,这是为什么啊?</P>
<P>在vb中的类似代码是没问题的。</P>
页: [1]
查看完整版本: [求助]vb.net 里这个错误是怎么回事啊?