CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    May 2005
    Posts
    64

    all the error constant = empty, why?

    all the error constant = empty, why?

    I use errorhandling:

    lResult = OleLoadPicture(pStream, UBound(bArr) + 1, 0, myGUID(0), myPic)
    Select Case lResult
    Case E_OUTOFMEMORY
    MsgBox "E_OUTOFMEMORY"
    Case E_UNEXPECTED
    MsgBox "E_UNEXPECTED"
    Case E_POINTER
    MsgBox "E_POINTER"
    Case E_NOINTERFACE
    MsgBox "E_NOINTERFACE"
    Case NO_ERROR
    Set Me.Picture = myPic
    MsgBox "Sucess!!!"
    End Select

    but all the constant (E_OUTOFMEMORY, ect..) = empty
    VB6 cant recognize the error code, why?

    im beginner in VB6, plz help

  2. #2
    Join Date
    Jun 2005
    Location
    Roma - Italy
    Posts
    46

    Re: all the error constant = empty, why?

    Have you correctly declared costants?

    Add Case 0 for success.
    Sorry for my english language!
    -------------------------------
    mrhyde.altervista.org
    Free resource
    ------------------------------

  3. #3
    Join Date
    Jul 2003
    Location
    Florida
    Posts
    651

    Re: all the error constant = empty, why?

    Make sure you use Option Explicit at the top of all your code modules. This forces you to declare all variables and will error if you have a variable that hasn't been declared. If E.Hyde is correct in that you have not properly declared your constants, having Option Explicit would have caught that and warned you.

    (In the Tools, Options menu, you can set up VB6 to automatically add Option Explicit to all new Code Modules.)
    I'd rather be wakeboarding...

  4. #4
    Join Date
    May 2005
    Posts
    64

    Red face Re: all the error constant = empty, why?

    no, I havent declared them. I thought the VB6 knows them. How can I declare COM error constants to work the code above?

  5. #5
    Join Date
    Jul 2003
    Location
    Florida
    Posts
    651

    Re: all the error constant = empty, why?

    Just replace the x's with the correct values of the Error Codes (which you will have to look up somewhere). If you declare them in the same code module as your function, you can leave them Private as long as nothing outside that code module is using them, otherwise, declare them as Public.
    Code:
    Private Const NO_ERROR As Integer = 0
    Private Const E_OUTOFMEMORY As Integer = x
    Private Const E_UNEXPECTED As Integer = x
    Private Const E_POINTER As Integer = x
    Private Const E_NOINTERFACE As Integer = x
    I'd rather be wakeboarding...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured