Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VB -> C#: CONVERSION ERROR: Conversion for OnErrorResumeNextStatement not implemented #1029

Closed
elmagekmosaad opened this issue Aug 7, 2023 · 1 comment
Labels
duplicate VB -> C# Specific to VB -> C# conversion

Comments

@elmagekmosaad
Copy link

VB.Net input code

If relevant, please enter some example VB.NET code here to reproduce the issue, or the steps taken to cause the issue.
`Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        On Error Resume Next
        Dim SaveFileDialog As SaveFileDialog = New SaveFileDialog
        Dim i As Integer
        SaveFileDialog.Title = "Save List.txt"
        SaveFileDialog.Filter = "List.txt File (*.txt)|*.txt"
        If SaveFileDialog.ShowDialog = DialogResult.OK Then
            Dim s As New IO.StreamWriter(SaveFileDialog.FileName, True)
            For i = 0 To ListBox1.Items.Count - 1
                s.WriteLine(ListBox1.Items.Item(i))
            Next
            s.Close()
            mginvoke(New Action(Sub() note.msg(str.str24)))
        End If
    End Sub`



simplification has errors: 
    CONVERSION ERROR: Conversion for OnErrorResumeNextStatement not implemented, please report this issue in 'On Error Resume Next' at character 2593
@elmagekmosaad elmagekmosaad added the VB -> C# Specific to VB -> C# conversion label Aug 7, 2023
@GrahamTheCoder
Copy link
Member

Hi, thanks for getting in touch. I'll close this as a duplicate of #426, but I'd be interested to know what your ideal behaviour would be in this scenario.

e.g. We could add a catch block and put a warning inside, then link to a page explaining how to add error handling in C#:
Ideally to handle specific exceptions with try blocks that are as small and targeted as possible, or to check for an issue that would cause an exception up front

private void Button3_Click(object sender, EventArgs e)
{
    try
    {
        var SaveFileDialog = new SaveFileDialog();
        int i;
        SaveFileDialog.Title = "Save List.txt";
        SaveFileDialog.Filter = "List.txt File (*.txt)|*.txt";
        if (SaveFileDialog.ShowDialog == DialogResult.OK)
        {
            var s = new StreamWriter(SaveFileDialog.FileName, true);
            var loopTo = ListBox1.Items.Count - 1;
            for (i = 0; i <= loopTo; i++)
                s.WriteLine(ListBox1.Items.Item(i));
            s.Close();
            mginvoke(new Action(() => note.msg(Conversion.str.str24)));
        }
    }
    catch (Exception e)
    {
        #warning Conversion issue: "On Error Resume Next" removed, please add error handling here
        // See https://github.com/icsharpcode/CodeConverter/wiki/OnErrorResumeNext for more information
    }
}

@GrahamTheCoder GrahamTheCoder closed this as not planned Won't fix, can't repro, duplicate, stale Aug 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate VB -> C# Specific to VB -> C# conversion
Projects
None yet
Development

No branches or pull requests

2 participants