none
to use the Raise Error Method. i am missing a bit of info about assigning vbObjectError+513 to the Number property. RRS feed

  • Question

  • in the code sample shown. 

    1. is vbObjectError just used to tell the value to assign to Number is to be treated as a run time error?

    2. as long as the number I use is 513 up to 65535 is ok? 

    Then what if I use 31036  that is listed as "Error saving to file"

    thanks, 

    Mark J

    Const MyContextID = 1010407    ' Define a constant for contextID.
    Function TestName(CurrentName, NewName)
        If Instr(NewName, "bob") Then    ' Test the validity of NewName.
            ' Raise the exception
            Err.Raise vbObjectError + 513, "MyProj.MyObject", _
            "No ""bob"" allowed in your name", "c:\MyProj\MyHelp.Hlp", _
            MyContextID
        End If
    End Function


    Mark J

    Wednesday, November 14, 2018 2:45 AM

All replies

  • Microsoft uses many error numbers above the range 1 - 512.

    vbObjectError = -2147221504. Error numbers from -2147221504 up aren't used or reserved by Microsoft, so there cannot be any confusion if you use them.

    For example, if you want to distinguish 10 different errors in your code, you could use vbObjectError + 1, vbObjectError + 2, …, vbObjectError + 10.


    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    Wednesday, November 14, 2018 9:47 AM
  • Hans,

    thanks again.  as always you have been verynhelpful.

    The incorrect way I was understanding this was the number I added to vbObjectError had to be a valid error number, like the Err.Number you get for a divide by zero error.


    Mark J

    Saturday, November 17, 2018 1:01 AM