We Are GAP Mobilize
Free Assessment Tool

VB to .NET

WARNING #6022

The CommonDialog CancelError property is not supported in Visual Basic .NET.

Description 

The property CommonDialog.CancelError is not currently supported by VBUC, nevertheless it is possible get a similar behavior or functionality by using .NET properties. 

Recommendations 

Understand how the CommonDialog.CancelError property is used in the VB6 source code and apply a manual change in order to emulate the behavior in the .NET platform. 

In .NET, the CommonDialog.ShowDialog() method shows the Dialog and after the dialog is closed, returns the information of the Dialog button that was pressed by the user. This returning value must be compared against the members of the System.Windows.Forms.DialogResult Enumeration 

Sample VB6 

Private Sub cmdColour_Click()
On Error GoTo errhandler
CommonDialog1.CancelError = True

' Display the Colour dialog box
CommonDialog1.ShowColor
' Set the forms background colour to the one selected
Me.BackColor = CommonDialog1.Color
Exit Sub
errhandler:
MsgBox "You canceled the dialog box"
End Sub

Target VB.NET 

Private Sub cmdColour_Click()
Try
'UPGRADE_ISSUE: (2064) MSComDlg.CommonDialog property CommonDialog1.CancelError was not upgraded.
CommonDialog1.setCancelError(True)

' Display the Colour dialog box
CommonDialog1Color.ShowDialog()
' Set the forms background colour to the one selected
Me.BackColor = CommonDialog1Color.Color
Catch
MessageBox.Show("You canceled the dialog box", My.Application.Info.Title)
End Try
End Sub

Target C# 

Private Sub cmdColour_Click()
Try
'UPGRADE_ISSUE: (2064) MSComDlg.CommonDialog property CommonDialog1.CancelError was not upgraded.
CommonDialog1.setCancelError(True)

' Display the Colour dialog box
CommonDialog1Color.ShowDialog()
' Set the forms background colour to the one selected
Me.BackColor = CommonDialog1Color.Color
Catch
MessageBox.Show("You canceled the dialog box", My.Application.Info.Title)
End Try
End Sub
Talk To An Engineer