MattL99
MattL99

Reputation: 137

Equivalent of "Error(Err.Number)" VB6 to VB.NET 2022

I have some VB6 code that needs to be migrated to VB.NET, and I wanted to inquire about this line of code, and see if there is a way to implement it in .NET

Error(Err.Number)

Keeps telling me that an Expression is expected.

If Err.Number = 53 Then
        GoTo x
    Else
        Msg = "      Error N. " & Err.Number & Chr(13) & Error(Err.Number)
        MsgBox(Msg, 16, "Warning")
        FileClose(1)
        Exit Sub
    End If

Upvotes: 3

Views: 590

Answers (1)

Brian M Stafford
Brian M Stafford

Reputation: 8868

The VB6 documentation states:

The return value of the Error function corresponds to the Description property of the Err object.

so instead of using Error(Err.Number) use Err.Description.

Upvotes: 8

Related Questions