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
Re: all the error constant = empty, why?
Have you correctly declared costants?
Add Case 0 for success.
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.)
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?
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