Documente online.
Zona de administrare documente. Fisierele tale
Am uitat parola x Creaza cont nou
 HomeExploreaza
upload
Upload




Tip 20: Define constants using a TypeLib or an Enum

software


Tip 20: Define constants using a TypeLib or an Enum.

When you create error values try not to use the so-called Magic Numbers. Thirteen is such a number, as in Err.Raise Number:=13. What does 13 mean? Basically it's a pain to resolve, so attempt always to use more meaningful names.



Visual Basic doesn't come with a set of symbolic constants defined for its own errors so I thought I'd put one together for you. Here's a snippet:

Public Enum vbErrorCodes
VBErrReturnWithoutGoSub = 3
VBErrInvalidProcedureCall = 5
VBErrOverflow = 6
VBErrOutOfMemory = 7
VBErrSubscriptOutOfRange = 9
VBErrThisArrayIsFixedOrTemporarilyLocked = 10
VBErrDivisionByZero = 11
VBErrTypeMismatch = 13
VBErrOutOfStringSpace = 14
VBErrExpressionTooComplex = 16
VBErrCantPerformRequestedOperation = 17
VBErrUserInterruptOccurred = 18
VBErrResumeWithoutError = 20
VBErrOutOfStackSpace = 28
VBErrSubFunctionOrPropertyNotDefined = 35
.
.
.
End Enum

Once you've added it to your project, this snippet is browsable via Visual Basic's Object Browser. You'll find the code on the companion CD. To see how you might define constants using a type library, see Chapter 7.


Document Info


Accesari: 1344
Apreciat: hand-up

Comenteaza documentul:

Nu esti inregistrat
Trebuie sa fii utilizator inregistrat pentru a putea comenta


Creaza cont nou

A fost util?

Daca documentul a fost util si crezi ca merita
sa adaugi un link catre el la tine in site


in pagina web a site-ului tau.




eCoduri.com - coduri postale, contabile, CAEN sau bancare

Politica de confidentialitate | Termenii si conditii de utilizare




Copyright © Contact (SCRIGROUP Int. 2024 )