tags:

views:

145

answers:

1

I have been given the task to re-code an old VB6 page. This page exports data from our database and imports it into another. While the export/import is happening, I need to offer the user confirm boxes. The context and results of these confirm boxes all depend on server-side validation. In the old code, the author simply did:

If MsgBox(Msg, vbOKCancel) = vbOK Then
                    GoTo Function1
                Else
                    GoTo Function2
                End If

Yes, those are GoTos, don't remind. This code is rough. Anyway, how in the heck can I do this in .NET with c# code behind?

+1  A: 

Well the code would be the same if it were C#, though it would look something like:

if (Interaction.MsgBox(Msg, Constants.vbOKCancel) == Constants.vbOK) {
    goto Function1;
}
else {
    goto Function2;
}

But, if this is an ASP.NET application, it would look different. You'd probably make a modal dialog box and attach some click handlers to the buttons on that dialog.

[edit] By the way, if you're ever in doubt about how VB code would look in C#, try a converter utility such as this one. They don't work all the time, but they work sometimes. Cheers.

hypoxide