Private Sub Form_Load()
Dim bytes(0 To 9) As Byte
Dim Valor As Variant
On Local Error GoTo showError
' OK....
Valor = 2009
Debug.Print Valor
MsgBox Valor
' ERROR: 13 error de tipo de variable
Valor = bytes
Debug.Print Valor
MsgBox Valor
MostrarValor (Valor)
' ERROR: 6 error de desbordamiento
Valor = 2009
Debug.Print Valor
MsgBox Valor
MostrarValor (Valor)
' ERROR: 450 error de tipo de argumentos...
Set Valor = Form1
MsgBox Valor
MostrarValor (Valor)
Exit Sub
showError:
MsgBox "Error: Nº " & Err.Number & vbCrLf & Err.Description & vbCrLf & Err.Source
Err.Clear
Resume Next
End Sub
Private Sub MostrarValor(ByVal n As Byte)
MsgBox n
End Sub