Why is it when I use Err.Raise 65536 the Err.Number will actually have the value of 5 and not 65536?
According to Raise definition: Sub Raise(Number As Long, [Source], [Description], [HelpFile], [HelpContext]). The passing parameter is Long and Err.Number is also Long.
So why can’t I use values greater then 65535?
Private Sub Command1_Click()
Dim a As Long
On Error GoTo ErrCatch
For a = 0 To 99999
Err.Raise a
DoEvents
Next a
Exit Sub
ErrCatch:
' this is where Err.Number is evaluated
Resume Next
End Sub`
From the MSDN documentation:
So even though you can submit a value larger than 65535, anything larger than 65535 will become Error 5.