Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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?

  • Administrators
Posted (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 by PlausiblyDamp

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted
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.
Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...