charlieb01
asked on
Object reference not set to an instance of an object
Hi,
Can anyone help me with this? I am getting this error in the line indicated below. (this is VB.NET 2003)
If I step through the code (using F11 key) the value of IsItSensor is TRUE when I enter the Sub. Also, the variable AinIsSensor(ix%) is Public Dim AinIsSensor() as Boolean. If I comment out this line I don't get the error and the rest of the code executes correctly. (I have only pasted a portion of this sub to save space).
Any Ideas?
Thanks,
Charlie
Sub AinDefXX(ByVal ix%, ByVal ScanOrder%, ByVal ChassisNum%, ByVal SlotNum%, ByVal chan%, ByVal UnB%, _
ByVal PhyTyp%, ByVal RngeTyp%, ByVal id$, ByVal aNam$, ByVal LimLo!, ByVal LimHi!, ByVal Group%, _
ByVal loMeas!, ByVal loReal!, ByVal medMeas!, ByVal medReal!, ByVal hiMeas!, ByVal hiReal!, _
ByVal OrderNum%, ByVal Nameshort$, ByVal IsItSensor As Boolean)
Dim j%, K%, msg$, x%
AinChanNum(ix%) = chan%
AinSlotNum(ix%) = SlotNum%
AinChassisNum(ix%) = ChassisNum%
AinScanOrder(ix%) = ScanOrder%
AinIsSensor(ix%) = IsItSensor ' <- The Error Occurs When Executing this Line
AinUnitBase%(ix%) = UnB%
AinPhysTyp%(ix%) = PhyTyp%
AinRngeTyp%(ix%) = RngeTyp%
Can anyone help me with this? I am getting this error in the line indicated below. (this is VB.NET 2003)
If I step through the code (using F11 key) the value of IsItSensor is TRUE when I enter the Sub. Also, the variable AinIsSensor(ix%) is Public Dim AinIsSensor() as Boolean. If I comment out this line I don't get the error and the rest of the code executes correctly. (I have only pasted a portion of this sub to save space).
Any Ideas?
Thanks,
Charlie
Sub AinDefXX(ByVal ix%, ByVal ScanOrder%, ByVal ChassisNum%, ByVal SlotNum%, ByVal chan%, ByVal UnB%, _
ByVal PhyTyp%, ByVal RngeTyp%, ByVal id$, ByVal aNam$, ByVal LimLo!, ByVal LimHi!, ByVal Group%, _
ByVal loMeas!, ByVal loReal!, ByVal medMeas!, ByVal medReal!, ByVal hiMeas!, ByVal hiReal!, _
ByVal OrderNum%, ByVal Nameshort$, ByVal IsItSensor As Boolean)
Dim j%, K%, msg$, x%
AinChanNum(ix%) = chan%
AinSlotNum(ix%) = SlotNum%
AinChassisNum(ix%) = ChassisNum%
AinScanOrder(ix%) = ScanOrder%
AinIsSensor(ix%) = IsItSensor ' <- The Error Occurs When Executing this Line
AinUnitBase%(ix%) = UnB%
AinPhysTyp%(ix%) = PhyTyp%
AinRngeTyp%(ix%) = RngeTyp%
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Roger,
I found it. I am trying to rebuild a program with several thousand pages of code that was written by about 10 other people. After some searching I discovered that the Vars are being Redimensioned elsewhere in the code based upon a recordset count.
Thanks for the help.
Charlie
I found it. I am trying to rebuild a program with several thousand pages of code that was written by about 10 other people. After some searching I discovered that the Vars are being Redimensioned elsewhere in the code based upon a recordset count.
Thanks for the help.
Charlie
Charlie
Thanks for the points. And for letting me know of the redimensioning. I must admit, on reading your earlier reply, that I was wondering whether there was a quirk about array declarations with type-suffixes that had escaped me.
Roger
Thanks for the points. And for letting me know of the redimensioning. I must admit, on reading your earlier reply, that I was wondering whether there was a quirk about array declarations with type-suffixes that had escaped me.
Roger
ASKER
This is the way it was:
Public AinScanOrder%()
Public AinIsSensor() As Boolean
I changed it to this:
Public AinScanOrder%()
Public AinIsSensor(200) As Boolean ' CRB - TRY USING A DIM OF 200 HERE (INSTEAD OF NOTHING)
That solved the problem but I don't understand why this error only occur with the Boolean and not the other variables. For example, AinScanOrder% is declared just as shown above and I don't get this error. I stepped through this until the value of ix% was 12 and still no error.
I would like to understand this better so if you could provide some insight it would be helpful.
Thanks,
Charlie