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