Home > Back-end >  Equivalent of "Error(Err.Number)" VB6 to VB.NET 2022
Equivalent of "Error(Err.Number)" VB6 to VB.NET 2022

Time:02-04

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

CodePudding user response:

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.

  •  Tags:  
  • Related