mjb3030 Posted February 4, 2004 Posted February 4, 2004 I have the following function: Function AllocBuffer(ByVal WinFlags As Integer, ByVal buffersize As Long) As Long Dim hbuf As Long Dim ecode As Long ecode = olDmAllocBuffer(WinFlags, buffersize, hbuf) If ecode <> OLNOERROR Then OLMEMTrap("AllocBuffer", ecode) Else AllocBuffer = hbuf End If End Function the olDmAllocBuffer function is defined as: Declare Function olDmAllocBuffer& Lib "OLMEM32.DLL" (ByVal usWinFlags%, ByVal ulBufferSize&, ByVal hBuffer&) An error of System.NullReference Exception or "Object reference not set to an instance of an object" is being thrown at the line ecode = olDmAllocBuffer(WinFlags, buffersize, hbuf) All of this code is contained in a module. I don't see any objects here other than longs and integers. This code works in VB6. What am I doing wrong? Quote
Administrators PlausiblyDamp Posted February 4, 2004 Administrators Posted February 4, 2004 (edited) Could you show a bit more code before the line ecode = olDmAllocBuffer(WinFlags, buffersize, hbuf) i.e. how are you initalizing WinFlags, buffersize and hbuf (which looks like it should point to some kind of buffer and may be the one that needs initializing) Edited February 4, 2004 by PlausiblyDamp Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
mjb3030 Posted February 4, 2004 Author Posted February 4, 2004 A value of 0 is being passed in for WinFlags, a value of 200 is being passed in for buffersize, and hbuf is the variable that will hold the result being returned from olDmAllocBuffer. Quote
mjb3030 Posted February 4, 2004 Author Posted February 4, 2004 I got it now. I just had to convert all my Longs to Integers. Quote
Recommended Posts