This section includes options to upgrade the common controls created by Microsoft and shipped with Visual Basic 6.0.
All these options have two choices: to upgrade using COM Interop and to upgrade using .NET native components. In general, it is recommended to use the .NET native components, although in some cases there might be some manual changes required to achieve functional equivalence.
1. MSACAL
Microsoft Calendar Control control.
1.1. To System.Windows.Forms.MonthCalendar
Convert MSACAL.Calendar to a .NET equivalent control.
By using this option the converted application will not have any references to the COM Component
Class
Maps to
MSACAL.Calendar
System.Windows.Forms.MonthCalendar
Original VB6 code:
Begin VB.Form Form1
...
Begin MSACAL.Calendar Calendar1
Height = 2895
Left = 120
TabIndex = 0
Top = 120
Width = 4335
...
End
End
Partial Class Form1
...
Public WithEvents Calendar1 As System.Windows.Forms.MonthCalendar
...
Private Sub InitializeComponent()
...
Me.Calendar1 = New System.Windows.Forms.MonthCalendar()
...
'
'Calendar1
'
Me.Calendar1.AllowDrop = True
Me.Calendar1.BackColor = System.Drawing.SystemColors.Control
Me.Calendar1.FirstDayOfWeek = System.Windows.Forms.Day.Sunday
Me.Calendar1.Font = New System.Drawing.Font("Arial", 8.25!, System.Drawing.FontStyle.Bold Or System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0)
Me.Calendar1.Font = New System.Drawing.Font("Arial", 8.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0)
Me.Calendar1.Font = New System.Drawing.Font("Arial", 12.0!, System.Drawing.FontStyle.Bold Or System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0)
Me.Calendar1.Location = New System.Drawing.Point(88, 56)
Me.Calendar1.Name = "Calendar1"
Me.Calendar1.TabIndex = 0
Me.Calendar1.TitleForeColor = System.Drawing.Color.Black
Me.Calendar1.TitleForeColor = System.Drawing.Color.FromArgb(0, 0, 160)
Me.Calendar1.Width = 113
1.2. To COM Interop
This feature will take the legacy COM control and create an interoperability code wrapper to make it visible from the managed code. This means the control's functionality will remain the same since it will use the same binary, but the resulting application will depend on the legacy control.
Original VB6 code:
Begin VB.Form Form1
...
Begin MSACAL.Calendar Calendar1
Height = 2895
Left = 120
TabIndex = 0
Top = 120
Width = 4335
...
End
End
Partial Class Form1
...
Public WithEvents DTPicker1 As System.Windows.Forms.DateTimePicker
Public WithEvents MonthView1 As System.Windows.Forms.MonthCalendar
...
Private Sub InitializeComponent()
...
Me.DTPicker1 = New System.Windows.Forms.DateTimePicker
...
Me.MonthView1 = New System.Windows.Forms.MonthCalendar
...
2.2. To COM Interop
This feature will take the legacy COM control and create an interoperability code wrapper to make it visible from the managed code. This means the control's functionality will remain the same since it will use the same binary, but the resulting application will depend on the legacy control.
Original VB6 code:
Begin VB.Form Form1
...
Begin MSComCtl2.DTPicker DTPicker1
...
End
Begin MSComCtl2.MonthView MonthView1
...
End
...
Partial Class Form1
...
Public WithEvents DTPicker1 As AxMSComCtl2.AxDTPicker
Public WithEvents MonthView1 As AxMSComCtl2.AxMonthView
...
Private Sub InitializeComponent()
...
Me.DTPicker1 = New AxMSComCtl2.AxDTPicker
Me.MonthView1 = New AxMSComCtl2.AxMonthView
...
3. MSComCtl
Microsoft Windows Common Controls Library
3.1. To native .NET component (System.Windows.Forms)
Convert Microsoft's MSComctlLib classes to System.Windows.Forms.
By using this option the converted application will not have any reference to the COM Component.
Class
Maps to
MSComctlLib.StatusBar
System.Windows.Forms.StatusStrip
MSComctlLib.ToolBar
System.Windows.Forms.ToolStrip
MSComctlLib.ImageList
System.Windows.Forms.ImageList
MSComctlLib.TabStrip
System.Windows.Forms.TabControl
MSComctlLib.TreeView
System.Windows.Forms.TreeView
MSComctlLib.ImageCombo
System.Windows.Forms.ComboBox
MSComctlLib.ListView
System.Windows.Forms.ListView
MSComctlLib.ProgressBar
System.Windows.Forms.ProgressBar
Original VB6 code:
Begin VB.Form Form1
...
Begin MSComctlLib.ImageCombo ImageCombo1
...
End
Begin MSComctlLib.Slider Slider1
...
End
Begin MSComctlLib.ImageList ImageList1
...
End
Begin MSComctlLib.ListView ListView1
...
End
Begin MSComctlLib.TreeView TreeView1
...
End
Begin MSComctlLib.ProgressBar ProgressBar1
...
End
Begin MSComctlLib.StatusBar StatusBar1
...
End
Begin MSComctlLib.TabStrip TabStrip1
...
End
Begin MSComctlLib.Toolbar Toolbar1
...
End
...
Partial Class Form1
...
Public WithEvents ImageCombo1 As System.Windows.Forms.ImageComboBox
Public WithEvents Slider1 As System.Windows.Forms.TrackBar
Public WithEvents ImageList1 As System.Windows.Forms.ImageList
Public WithEvents ListView1 As System.Windows.Forms.ListView
Public WithEvents TreeView1 As System.Windows.Forms.TreeView
Public WithEvents ProgressBar1 As System.Windows.Forms.ProgressBar
Private WithEvents _StatusBar1_Panel1 As System.Windows.Forms.ToolStripStatusLabel
Public WithEvents StatusBar1 As System.Windows.Forms.StatusStrip
Private WithEvents _TabStrip1_Tab1 As System.Windows.Forms.TabPage
Public WithEvents TabStrip1_Tabs As System.Windows.Forms.TabControl.TabPageCollection
Public WithEvents TabStrip1 As System.Windows.Forms.TabControl
Public WithEvents Toolbar1 As System.Windows.Forms.ToolStrip
...
Private Sub InitializeComponent()
...
Me.ImageCombo1 = New System.Windows.Forms.ImageComboBox
Me.Slider1 = New System.Windows.Forms.TrackBar
Me.ImageList1 = New System.Windows.Forms.ImageList
Me.ListView1 = New System.Windows.Forms.ListView
Me.TreeView1 = New System.Windows.Forms.TreeView
Me.ProgressBar1 = New System.Windows.Forms.ProgressBar
Me.StatusBar1 = New System.Windows.Forms.StatusStrip
Me._StatusBar1_Panel1 = New System.Windows.Forms.ToolStripStatusLabelo
Me.TabStrip1 = New System.Windows.Forms.TabControl
Me.TabStrip1_Tabs = New System.Windows.Forms.TabControl.TabPageCollection(TabStrip1)
Me._TabStrip1_Tab1 = New System.Windows.Forms.TabPage
Me.Toolbar1 = New System.Windows.Forms.ToolStrip
...
3.2. To COM Interop
This feature will take the legacy COM control and create an interoperability code wrapper to make it visible from the managed code. This means the control's functionality will remain the same since it will use the same binary, but the resulting application will depend on the legacy control.
Original VB6 code:
Begin VB.Form Form1
...
Begin MSComctlLib.ImageCombo ImageCombo1
...
End
Begin MSComctlLib.Slider Slider1
...
End
Begin MSComctlLib.ImageList ImageList1
...
End
Begin MSComctlLib.ListView ListView1
...
End
Begin MSComctlLib.TreeView TreeView1
...
End
Begin MSComctlLib.ProgressBar ProgressBar1
...
End
Begin MSComctlLib.StatusBar StatusBar1
...
End
Begin MSComctlLib.TabStrip TabStrip1
...
End
Begin MSComctlLib.Toolbar Toolbar1
...
End
...
Partial Class Form1
...
Public WithEvents ImageCombo1 As AxMSComctlLib.AxImageCombo
Public WithEvents Slider1 As AxMSComctlLib.AxSlider
Public WithEvents ImageList1 As AxMSComctlLib.AxImageList
Public WithEvents ListView1 As AxMSComctlLib.AxListView
Public WithEvents TreeView1 As AxMSComctlLib.AxTreeView
Public WithEvents ProgressBar1 As AxMSComctlLib.AxProgressBar
Public WithEvents StatusBar1 As AxMSComctlLib.AxStatusBar
Public WithEvents TabStrip1 As AxMSComctlLib.AxTabStrip
Public WithEvents Toolbar1 As AxMSComctlLib.AxToolbar
...
Private Sub InitializeComponent()
...
Me.ImageCombo1 = New AxMSComctlLib.AxImageCombo
Me.Slider1 = New AxMSComctlLib.AxSlider
Me.ImageList1 = New AxMSComctlLib.AxImageList
Me.ListView1 = New AxMSComctlLib.AxListView
Me.TreeView1 = New AxMSComctlLib.AxTreeView
Me.ProgressBar1 = New AxMSComctlLib.AxProgressBar
Me.StatusBar1 = New AxMSComctlLib.AxStatusBar
Me.TabStrip1 = New AxMSComctlLib.AxTabStrip
Me.Toolbar1 = New AxMSComctlLib.AxToolbar
...
4. MSComDlg
Microsoft Common Dialog Control Library
4.1. To native .NET component (System.Windows.Forms)
The MSComDlg CommonDialog control is used to display several types of dialogs: open file, save file, printer, color, and font dialogs. In .NET there are different types of dialog controls according to the necessity.
The Visual Basic Upgrade Companion converts the CommonDialog according to its use in the Visual Basic 6.0 source code to the following alternative controls: ColorDialog, FontDialog, OpenDialog, SaveDialog, and PrintDialog.
By using this option the converted application will not have any reference to the COM Component.
Original VB6 code:
Begin VB.Form Form1
...
Begin MSComDlg.CommonDialog CommonDialog_Save
...
End
Begin MSComDlg.CommonDialog CommonDialog_Open
...
End
Begin MSComDlg.CommonDialog CommonDialog_Printer
...
End
Begin MSComDlg.CommonDialog CommonDialog_Font
...
End
Begin MSComDlg.CommonDialog CommonDialog_Color
...
End
Begin MSComDlg.CommonDialog CommonDialog_Help
...
End
...
Partial Class Form1
...
Public CommonDialog_SaveSave As System.Windows.Forms.SaveFileDialog
Public CommonDialog_OpenOpen As System.Windows.Forms.OpenFileDialog
Public CommonDialog_PrinterPrint As System.Windows.Forms.PrintDialog
Public CommonDialog_FontFont As System.Windows.Forms.FontDialog
Public CommonDialog_ColorColor As System.Windows.Forms.ColorDialog
...
Private Sub InitializeComponent()
...
Me.CommonDialog_SaveSave = New System.Windows.Forms.SaveFileDialog
Me.CommonDialog_OpenOpen = New System.Windows.Forms.OpenFileDialog
Me.CommonDialog_PrinterPrint = New System.Windows.Forms.PrintDialog
Me.CommonDialog_PrinterPrint.PrinterSettings = New System.Drawing.Printing.PrinterSettings
Me.CommonDialog_FontFont = New System.Windows.Forms.FontDialog
Me.CommonDialog_ColorColor = New System.Windows.Forms.ColorDialog
...
4.2. To COM Interop
This feature will take the legacy COM control and create an interoperability code wrapper to make it visible from the managed code. This means the control's functionality will remain the same since it will use the same binary, but the resulting application will depend on the legacy control.
Original VB6 code:
Begin VB.Form Form1
...
Begin MSComDlg.CommonDialog CommonDialog_Save
...
End
Begin MSComDlg.CommonDialog CommonDialog_Open
...
End
Begin MSComDlg.CommonDialog CommonDialog_Printer
...
End
Begin MSComDlg.CommonDialog CommonDialog_Font
...
End
Begin MSComDlg.CommonDialog CommonDialog_Color
...
End
Begin MSComDlg.CommonDialog CommonDialog_Help
...
End
...
Partial Class Form1
...
Public WithEvents CommonDialog_Save As AxMSComDlg.AxCommonDialog
Public WithEvents CommonDialog_Open As AxMSComDlg.AxCommonDialog
Public WithEvents CommonDialog_Printer As AxMSComDlg.AxCommonDialog
Public WithEvents CommonDialog_Font As AxMSComDlg.AxCommonDialog
Public WithEvents CommonDialog_Color As AxMSComDlg.AxCommonDialog
Public WithEvents CommonDialog_Help As AxMSComDlg.AxCommonDialog
...
Private Sub InitializeComponent()
...
Me.CommonDialog_Save = New AxMSComDlg.AxCommonDialog
Me.CommonDialog_Open = New AxMSComDlg.AxCommonDialog
Me.CommonDialog_Printer = New AxMSComDlg.AxCommonDialog
Me.CommonDialog_Font = New AxMSComDlg.AxCommonDialog
Me.CommonDialog_Color = New AxMSComDlg.AxCommonDialog
Me.CommonDialog_Help = New AxMSComDlg.AxCommonDialog
...
5. DataCombo
5.1. To System.Windows.Forms.ComboBox
Convert Microsoft's MSDataList.DataCombo classes to System.Windows.Forms.
By using this option the converted application will not have any reference to the COM Component.
Class
Maps to
MSDataListLib.DataCombo.ListField
System.Windows.Forms.DisplayMember
MSDataListLib.DataCombo.BoundColumns
System.Windows.Forms.ValueMember
MSDataListLib.DataCombo.BoundText
System.Windows.Forms.SelectedValue
MSDataListLib.DataCombo.Height
System.Windows.Forms.Height
MSDataListLib.DataCombo.Width
System.Windows.Forms.Width
MSDataListLib.DataCombo.Text
System.Windows.Forms.Text
MSDataListLib.DataCombo.SelectedItem
System.Windows.Forms.SelectedIndex
MSDataListLib.DataCombo.SetFocus
System.Windows.Forms.Focus
Original VB6 code:
Private Sub Form_Load()
Me.DataCombo1.Enabled = False
Me.DataCombo1.Text = "Hello"
Call Me.Refresh
End Sub
Private Sub Form_Load()
Me.DataCombo1.Enabled = False
Me.DataCombo1.Text = "Hello"
Me.Refresh()
End Sub
5.2. To COM Interop
This feature will take the legacy COM control and create an interoperability code wrapper to make it visible from the managed code. This means the control's functionality will remain the same since it will use the same binary, but the resulting application will depend on the legacy control.
Original VB6 code:
Private Sub Form_Load()
Me.DataCombo1.Enabled = False
Me.DataCombo1.Text = "Hello"
Call Me.Refresh
End Sub
Private Sub Form_Load()
Me.DataCombo1.Enabled = False
Me.DataCombo1.CtlText = "Hello"
Me.Refresh()
End Sub
6. MSMask
Microsoft Mask Edit Control Library
6.1. To System.Windows.Forms.MaskedTextBox
Convert Microsoft's MSMask classes to System.Windows.Forms.
By using this option the converted application will not have any reference to the COM Component.
Class
Maps to
MSMask.MaskedBox
System.Windows.Forms.MaskedTextBox
MSMask.ClipModeConstants
System.Windows.Forms.MaskFormat
MSMask.BorderStyleConstants
System.Windows.Forms.BorderStyle
MSMask.MousePointerConstants
System.Windows.Forms.Cursor
Original VB6 code:
Begin VB.Form Form1
...
Begin MSMask.MaskEdBox MaskEdBox1
Height = 495
Left = 1200
TabIndex = 0
Top = 240
Width = 2055
_ExtentX = 3625
_ExtentY = 873
_Version = 393216
PromptChar = "_"
End
...
C# code:
partialclassForm1{ ...publicSystem.Windows.Forms.MaskedTextBox MaskEdBox1; ...privatevoidInitializeComponent() {...this.MaskEdBox1=newSystem.Windows.Forms.MaskedTextBox();...this.MaskEdBox1.AllowPromptAsInput=false;this.MaskEdBox1.Font=newSystem.Drawing.Font("Microsoft Sans Serif",8f,System.Drawing.FontStyle.Regular,System.Drawing.GraphicsUnit.Point,0);this.MaskEdBox1.Location=newSystem.Drawing.Point(80,16);this.MaskEdBox1.Name="MaskEdBox1";this.MaskEdBox1.PromptChar='_';this.MaskEdBox1.Size=newSystem.Drawing.Size(137,33);this.MaskEdBox1.TabIndex=0;... }}
VB.NET code:
Partial Class Form1
...
Public WithEvents MaskEdBox1 As System.Windows.Forms.MaskedTextBox
...
Private Sub InitializeComponent()
...
Me. MaskEdBox1= New System.Windows.Forms.MaskedTextBox
...
Me.MaskEdBox1.AllowPromptAsInput = False
Me.MaskEdBox1.Font = New System.Drawing.Font("Microsoft Sans Serif", 8!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0)
Me.MaskEdBox1.Location = New System.Drawing.Point(80, 16)
Me.MaskEdBox1.Name = "MaskEdBox1"
Me.MaskEdBox1.PromptChar = "_"c
Me.MaskEdBox1.Size = New System.Drawing.Size(137, 33)
Me.MaskEdBox1.TabIndex = 0
...
6.2. To COM Interop
This feature will take the legacy COM control and create an interoperability code wrapper to make it visible from the managed code. This means the control's functionality will remain the same since it will use the same binary, but the resulting application will depend on the legacy control.
Original VB6 code:
Begin VB.Form Form1
...
Begin MSMask.MaskEdBox MaskEdBox1
Height = 495
Left = 1200
TabIndex = 0
Top = 240
Width = 2055
_ExtentX = 3625
_ExtentY = 873
_Version = 393216
PromptChar = "_"
End
...
By using this option the converted application will not have any reference to the COM Component.
This upgrade option is only available for .NET framework and is not available for .NET 6 or higher.
Class
Maps to
MSMQ.MSMQQueueInfo
System.Messaging.MessageQueue
MSMQ.MSMQQueue
System.Messaging.MessageQueue
MSMQ.MSMQMessage
System.Messaging.Message
MSMQ.MSMQQueueInfos
Array of System.Messaging.MessageQueue
MSMQ.MSMQTransactionDispenser
System.Messaging.MessageQueueTransaction
MSMQ.MSMQTransactionDispenser
System.Messaging.MessageQueueTransaction
MSMQ.MSMQCoordinatedTransactionDispenser
System.Messaging.MessageQueueTransaction
Original VB6 Code:
Dim qInfo As MSMQ.MSMQQueueInfo
Dim q As MSMQ.MSMQQueue
Dim msg As MSMQ.MSMQMessage
Dim qInfos As MSMQ.MSMQQueueInfos
Dim query As MSMQ.MSMQQuery
Dim dispenser As MSMQ.MSMQTransactionDispenser
Dim transaction As MSMQ.MSMQTransaction
Private Sub Command1_Click()
Set q = New MSMQ.MSMQQueue
Set query = New MSMQ.MSMQQuery
Set dispenser = New MSMQ.MSMQTransactionDispenser
Set transaction = New MSMQ.MSMQTransaction
Set qInfo = New MSMQ.MSMQQueueInfo
qInfo.PathName = ".\Private$\testqueue6"
Set q = qInfo.Open(MQ_SEND_ACCESS, MQ_DENY_NONE)
' Create a new message
Set msg = New MSMQ.MSMQMessage
Set transaction = dispenser.BeginTransaction
msg.Body = "Hello, MSMQ were set with the properties ,'Delivery', 'Priority', 'Journal'!"
msg.Delivery = MQMSG_DELIVERY_EXPRESS
msg.Priority = MQ_MAX_PRIORITY
msg.Journal = 1
msg.Send q, transaction
transaction.Commit
MsgBox "Message sent successfully", vbInformation
q.Close
Set q = Nothing
' Get Public Queues
Set qInfos = query.LookupQueue(ServiceTypeGuid:="{00000000-0000-0000-0000-000000000004}")
End Sub
C# Code:
partialclassForm1:System.Windows.Forms.Form{ ...System.Messaging.MessageQueue qInfo =null;System.Messaging.MessageQueue q =null;System.Messaging.Message msg =null;System.Messaging.MessageQueue[] qInfos =null; //UPGRADE_ISSUE: (2068) MSMQ.MSMQQuery object was not upgraded. More Information: https://docs.mobilize.net/vbuc/ewis#2068UpgradeStubs.MSMQ_MSMQQuery query =null;System.Messaging.MessageQueueTransaction dispenser =null;System.Messaging.MessageQueueTransaction transaction =null;privatevoidCommand1_Click(Object eventSender,EventArgs eventArgs) { q =newSystem.Messaging.MessageQueue(); //UPGRADE_ISSUE: (2068) MSMQ.MSMQQuery object was not upgraded. More Information: https://docs.mobilize.net/vbuc/ewis#2068 query =newUpgradeStubs.MSMQ_MSMQQuery(); dispenser =newSystem.Messaging.MessageQueueTransaction(); transaction =newSystem.Messaging.MessageQueueTransaction(); qInfo =newSystem.Messaging.MessageQueue();qInfo.Path=".\\Private$\\testqueue6"; //UPGRADE_WARNING: (2065) MSMQ.MSMQQueueInfo method qInfo.Open has a new behavior. More Information: https://docs.mobilize.net/vbuc/ewis#2065 q = (System.Messaging.MessageQueue) (qInfo =newSystem.Messaging.MessageQueue(qInfo.Path,false,false,System.Messaging.QueueAccessMode.Send)); // Create a new message msg =newSystem.Messaging.Message();dispenser.Begin(); transaction = (System.Messaging.MessageQueueTransaction) dispenser;msg.Body="Hello, MSMQ were set with the properties ,'Delivery', 'Priority', 'Journal'!";msg.Recoverable=false;msg.Priority=System.Messaging.MessagePriority.Highest;msg.UseJournalQueue=true; //UPGRADE_WARNING: (2065) MSMQ.MSMQMessage method msg.Send has a new behavior. More Information: https://docs.mobilize.net/vbuc/ewis#2065q.Send(msg);transaction.Commit();MessageBox.Show("Message sent successfully",AssemblyHelper.GetTitle(System.Reflection.Assembly.GetExecutingAssembly()),MessageBoxButtons.OK,MessageBoxIcon.Information);q.Close(); q =null; // Get Public Queues qInfos = (System.Messaging.MessageQueue[]) System.Messaging.MessageQueue.GetPublicQueuesByCategory(newGuid("{00000000-0000-0000-0000-000000000004}")); } ...}
VB.NET Code:
Partial Class Form1
Inherits System.Windows.Forms.Form
...
Dim qInfo As System.Messaging.MessageQueue
Dim q As System.Messaging.MessageQueue
Dim msg As System.Messaging.Message
Dim qInfos() As System.Messaging.MessageQueue
'UPGRADE_ISSUE: (2068) MSMQ.MSMQQuery object was not upgraded. More Information: https://docs.mobilize.net/vbuc/ewis#2068
Dim query As MSMQ_DocumentationSupport.UpgradeStubs.MSMQ_MSMQQuery
Dim dispenser As System.Messaging.MessageQueueTransaction
Dim transaction As System.Messaging.MessageQueueTransaction
Private Sub Command1_Click(ByVal eventSender As Object, ByVal eventArgs As EventArgs) Handles Command1.Click
q = New System.Messaging.MessageQueue()
'UPGRADE_ISSUE: (2068) MSMQ.MSMQQuery object was not upgraded. More Information: https://docs.mobilize.net/vbuc/ewis#2068
query = New MSMQ_DocumentationSupport.UpgradeStubs.MSMQ_MSMQQuery()
dispenser = New System.Messaging.MessageQueueTransaction()
transaction = New System.Messaging.MessageQueueTransaction()
qInfo = New System.Messaging.MessageQueue()
qInfo.Path = ".\Private$\testqueue6"
qInfo = New System.Messaging.MessageQueue(qInfo.Path, False, False, System.Messaging.QueueAccessMode.Send)
'UPGRADE_WARNING: (2065) MSMQ.MSMQQueueInfo method qInfo.Open has a new behavior. More Information: https://docs.mobilize.net/vbuc/ewis#2065
q = qInfo
' Create a new message
msg = New System.Messaging.Message()
dispenser.Begin()
transaction = dispenser
msg.Body = "Hello, MSMQ were set with the properties ,'Delivery', 'Priority', 'Journal'!"
msg.Recoverable = False
msg.Priority = System.Messaging.MessagePriority.Highest
msg.UseJournalQueue = True
'UPGRADE_WARNING: (2065) MSMQ.MSMQMessage method msg.Send has a new behavior. More Information: https://docs.mobilize.net/vbuc/ewis#2065
q.Send(msg)
transaction.Commit()
MessageBox.Show("Message sent successfully", My.Application.Info.Title, MessageBoxButtons.OK, MessageBoxIcon.Information)
q.Close()
q = Nothing
' Get Public Queues
qInfos = System.Messaging.MessageQueue.GetPublicQueuesByCategory(New Guid("{00000000-0000-0000-0000-000000000004}"))
End Sub
End Class
7.2. To COM Interop
This feature will take the legacy COM library and create an interoperability code wrapper to make it visible from the managed code. This means the library functionality will remain the same since it will use the same binary, but the resulting application will depend on the legacy library.
Original VB6 Code:
Dim qInfo As MSMQ.MSMQQueueInfo
Dim q As MSMQ.MSMQQueue
Dim msg As MSMQ.MSMQMessage
Dim qInfos As MSMQ.MSMQQueueInfos
Dim query As MSMQ.MSMQQuery
Dim dispenser As MSMQ.MSMQTransactionDispenser
Dim transaction As MSMQ.MSMQTransaction
Private Sub Command1_Click()
Set q = New MSMQ.MSMQQueue
Set query = New MSMQ.MSMQQuery
Set dispenser = New MSMQ.MSMQTransactionDispenser
Set transaction = New MSMQ.MSMQTransaction
Set qInfo = New MSMQ.MSMQQueueInfo
qInfo.PathName = ".\Private$\testqueue6"
Set q = qInfo.Open(MQ_SEND_ACCESS, MQ_DENY_NONE)
' Create a new message
Set msg = New MSMQ.MSMQMessage
Set transaction = dispenser.BeginTransaction
msg.Body = "Hello, MSMQ were set with the properties ,'Delivery', 'Priority', 'Journal'!"
msg.Delivery = MQMSG_DELIVERY_EXPRESS
msg.Priority = MQ_MAX_PRIORITY
msg.Journal = 1
msg.Send q, transaction
transaction.Commit
MsgBox "Message sent successfully", vbInformation
q.Close
Set q = Nothing
' Get Public Queues
Set qInfos = query.LookupQueue(ServiceTypeGuid:="{00000000-0000-0000-0000-000000000004}")
End Sub
Partial Friend Class Form1
Inherits System.Windows.Forms.Form
...
Dim qInfo As MSMQ.MSMQQueueInfo
Dim q As MSMQ.MSMQQueue
Dim msg As MSMQ.MSMQMessage
Dim qInfos As MSMQ.MSMQQueueInfos
Dim query As MSMQ.MSMQQuery
Dim dispenser As MSMQ.MSMQTransactionDispenser
Dim transaction As MSMQ.MSMQTransaction
Private Sub Command1_Click(ByVal eventSender As Object, ByVal eventArgs As EventArgs) Handles Command1.Click
q = New MSMQ.MSMQQueue()
query = New MSMQ.MSMQQuery()
dispenser = New MSMQ.MSMQTransactionDispenser()
transaction = New MSMQ.MSMQTransaction()
qInfo = New MSMQ.MSMQQueueInfo()
qInfo.PathName = ".\Private$\testqueue6"
q = qInfo.Open(MSMQ.MQACCESS.MQ_SEND_ACCESS, MSMQ.MQSHARE.MQ_DENY_NONE)
' Create a new message
msg = New MSMQ.MSMQMessage()
transaction = dispenser.BeginTransaction()
msg.Body = "Hello, MSMQ were set with the properties ,'Delivery', 'Priority', 'Journal'!"
msg.Delivery = MSMQ.MQMSGDELIVERY.MQMSG_DELIVERY_EXPRESS
msg.Priority = MSMQ.MQPRIORITY.MQ_MAX_PRIORITY
msg.Journal = 1
msg.Send(q, transaction)
transaction.Commit()
MessageBox.Show("Message sent successfully", My.Application.Info.Title, MessageBoxButtons.OK, MessageBoxIcon.Information)
q.Close()
q = Nothing
' Get Public Queues
qInfos = query.LookupQueue(Nothing, "{00000000-0000-0000-0000-000000000004}")
End Sub
End Class
8. MSWLess
Microsoft Windowless Controls Library
8.1. To System.Windows.Forms controls
Convert Microsoft's MSWLess to System.Windows.Forms .NET component controls.
By using this option the converted application will not have any reference to the COM Component.
Class
Maps to
MSWLess.WLCheck
System.Windows.Forms.CheckBox
MSWLess.WLCombo
System.Windows.Forms.ComboBox
MSWLess.WLText
System.Windows.Forms.TextBox
MSWLess.AlignmentConstants
System.Drawing.ContentAlignment
MSWLess.CheckValueConstants
System.Windows.Forms.CheckState
MSWLess.StyleComboConstants
System.Windows.Forms.ComboBoxStyle
MSWLess.ScrollBarsConstants
System.Windows.Forms.ScrollBars
Original VB6 code:
Begin VB.Form Form1
...
Begin MSWLess.WLText WLText1
Height = 375
Left = 0
TabIndex = 2
Top = 1080
Width = 2055
_ExtentX = 3625
_ExtentY = 661
_Version = 393216
Text = "WLText1"
ForeColor = -2147483640
BackColor = -2147483643
BorderStyle = 1
Appearance = 1
End
Begin MSWLess.WLCombo WLCombo1
Height = 315
Left = 0
TabIndex = 1
Top = 720
Width = 2055
_ExtentX = 3625
_ExtentY = 556
_Version = 393216
ListCount = 9404
Text = "WLCombo1"
ForeColor = -2147483640
BackColor = -2147483643
Appearance = 1
List = "Form1.frx":0000
End
Begin MSWLess.WLCheck WLCheck1
Height = 495
Left = 120
TabIndex = 0
Top = 120
Width = 1815
_ExtentX = 3201
_ExtentY = 873
_Version = 393216
Caption = "WLCheck1"
Appearance = 1
End
...
...
C# code:
partialclassForm1{ ...publicSystem.Windows.Forms.TextBox WLText1;publicSystem.Windows.Forms.ComboBox WLCombo1;publicSystem.Windows.Forms.CheckBox WLCheck1; ...privatevoidInitializeComponent() {...this.WLText1=newSystem.Windows.Forms.TextBox();this.WLCombo1=newSystem.Windows.Forms.ComboBox();this.WLCheck1=newSystem.Windows.Forms.CheckBox(); // //WLText1 // this.WLText1.BackColor=System.Drawing.SystemColors.Window;this.WLText1.Font=newSystem.Drawing.Font("Microsoft Sans Serif",8f,System.Drawing.FontStyle.Regular,System.Drawing.GraphicsUnit.Point,0);this.WLText1.ForeColor=System.Drawing.SystemColors.WindowText;this.WLText1.Location=newSystem.Drawing.Point(0,72);this.WLText1.Name="WLText1";this.WLText1.Size=newSystem.Drawing.Size(137,25);this.WLText1.TabIndex=2;this.WLText1.Text="WLText1"; // //WLCombo1 // this.WLCombo1.BackColor=System.Drawing.SystemColors.Window;this.WLCombo1.Font=newSystem.Drawing.Font("Microsoft Sans Serif",8f,System.Drawing.FontStyle.Regular,System.Drawing.GraphicsUnit.Point,0);this.WLCombo1.ForeColor=System.Drawing.SystemColors.WindowText;this.WLCombo1.Location=newSystem.Drawing.Point(0,48);this.WLCombo1.Name="WLCombo1";this.WLCombo1.Size=newSystem.Drawing.Size(137,21);this.WLCombo1.TabIndex=1;this.WLCombo1.Text="WLCombo1"; // //WLCheck1 // this.WLCheck1.Font=newSystem.Drawing.Font("Microsoft Sans Serif",8f,System.Drawing.FontStyle.Regular,System.Drawing.GraphicsUnit.Point,0);this.WLCheck1.Location=newSystem.Drawing.Point(8,8);this.WLCheck1.Name="WLCheck1";this.WLCheck1.Size=newSystem.Drawing.Size(121,33);this.WLCheck1.TabIndex=0;this.WLCheck1.Text="WLCheck1";... }}
VB.NET code:
Partial Class Form1
...
Public WithEvents WLText1 As System.Windows.Forms.TextBox
Public WithEvents WLCombo1 As System.Windows.Forms.ComboBox
Public WithEvents WLCheck1 As System.Windows.Forms.CheckBox
...
Private Sub InitializeComponent()
...
Me.WLText1 = New System.Windows.Forms.TextBox
Me.WLCombo1 = New System.Windows.Forms.ComboBox
Me.WLCheck1 = New System.Windows.Forms.CheckBox
''
'WLText1
'
Me.WLText1.BackColor = System.Drawing.SystemColors.Window
Me.WLText1.Font = New System.Drawing.Font("Microsoft Sans Serif", 8!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0)
Me.WLText1.ForeColor = System.Drawing.SystemColors.WindowText
Me.WLText1.Location = New System.Drawing.Point(0, 72)
Me.WLText1.Name = "WLText1"
Me.WLText1.Size = New System.Drawing.Size(137, 25)
Me.WLText1.TabIndex = 2
Me.WLText1.Text = "WLText1"
''
' WLCombo1
'
Me.WLCombo1.BackColor = System.Drawing.SystemColors.Window
Me.WLCombo1.Font = New System.Drawing.Font("Microsoft Sans Serif", 8!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0)
Me.WLCombo1.ForeColor = System.Drawing.SystemColors.WindowText
Me.WLCombo1.Location = New System.Drawing.Point(0, 48)
Me.WLCombo1.Name = "WLCombo1"
Me.WLCombo1.Size = New System.Drawing.Size(137, 21)
Me.WLCombo1.TabIndex = 1
Me.WLCombo1.Text = "WLCombo1"
''
'WLCheck1
'
Me.WLCheck1.Font = New System.Drawing.Font("Microsoft Sans Serif", 8!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0)
Me.WLCheck1.Location = New System.Drawing.Point(8, 8)
Me.WLCheck1.Name = "WLCheck1"
Me.WLCheck1.Size = New System.Drawing.Size(121, 33)
Me.WLCheck1.TabIndex = 0
Me.WLCheck1.Text = "WLCheck1"
...
8.2. To COM Interop
This feature will take the legacy COM control and create an interoperability code wrapper to make it visible from the managed code. This means the control's functionality will remain the same since it will use the same binary, but the resulting application will depend on the legacy control.
Original VB6 code:
Begin VB.Form Form1
...
Begin MSWLess.WLText WLText1
Height = 375
Left = 0
TabIndex = 2
Top = 1080
Width = 2055
_ExtentX = 3625
_ExtentY = 661
_Version = 393216
Text = "WLText1"
ForeColor = -2147483640
BackColor = -2147483643
BorderStyle = 1
Appearance = 1
End
Begin MSWLess.WLCombo WLCombo1
Height = 315
Left = 0
TabIndex = 1
Top = 720
Width = 2055
_ExtentX = 3625
_ExtentY = 556
_Version = 393216
ListCount = 9404
Text = "WLCombo1"
ForeColor = -2147483640
BackColor = -2147483643
Appearance = 1
List = "Form1.frx":0000
End
Begin MSWLess.WLCheck WLCheck1
Height = 495
Left = 120
TabIndex = 0
Top = 120
Width = 1815
_ExtentX = 3201
_ExtentY = 873
_Version = 393216
Caption = "WLCheck1"
Appearance = 1
End
...
...
Partial Class Form1
...
Public WithEvents WLText1 As AxMSWLess.AxWLText
Public WithEvents WLCombo1 As AxMSWLess.AxWLCombo
Public WithEvents WLCheck1 As AxMSWLess.AxWLCheck
...
Private Sub InitializeComponent()
...
Me.WLText1 = New AxMSWLess.AxWLText
Me.WLCombo1 = New AxMSWLess.AxWLCombo
Me.WLCheck1 = New AxMSWLess.AxWLCheck
''
'WLText1
'
Me.WLText1.Location = New System.Drawing.Point(0, 72)
Me.WLText1.Name = "WLText1"
Me.WLText1.OcxState = CType(resources.GetObject("WLText1.OcxState"), System.Windows.Forms.AxHost.State)
Me.WLText1.Size = New System.Drawing.Size(137, 25)
Me.WLText1.TabIndex = 2
''
'WLCombo1
'
Me.WLCombo1.Location = New System.Drawing.Point(0, 48)
Me.WLCombo1.Name = "WLCombo1"
Me.WLCombo1.OcxState = CType(resources.GetObject("WLCombo1.OcxState"), System.Windows.Forms.AxHost.State)
Me.WLCombo1.Size = New System.Drawing.Size(137, 21)
Me.WLCombo1.TabIndex = 1
''
'WLCheck1
'
Me.WLCheck1.Location = New System.Drawing.Point(8, 8)
Me.WLCheck1.Name = "WLCheck1"
Me.WLCheck1.OcxState = CType(resources.GetObject("WLCheck1.OcxState"), System.Windows.Forms.AxHost.State)
Me.WLCheck1.Size = New System.Drawing.Size(121, 33)
Me.WLCheck1.TabIndex = 0
...
9. MSXML2
Microsoft XML2 Library
9.1.To System.Xml classes
Convert Microsoft's MSXML2 library to System.Xml .NET classes.
By using this option the converted application will not have any reference to the COM Component.
Class
Maps to
MSXML2.DOMDocument
System.Xml.XmlDocument
MSXML2.DOMNodeType
System.Xml.XmlNodeType
MSXML2.IXMLDOMAttribute
System.Xml.XmlAttribute
MSXML2.IXMLDOMCDATASection
System.Xml.XmlCDataSection
MSXML2.IXMLDOMDocument
System.Xml.XmlDocument
MSXML2.IXMLDOMElement
System.Xml.XmlElement
MSXML2.IXMLDOMNamedNodeMap
System.Xml.XmlNamedNodeMap
MSXML2.IXMLDOMNode
System.Xml.XmlNode
MSXML2.IXMLDOMNodeList
System.Xml.XmlNodeList
MSXML2.IXMLDOMParseError
System.Exception
MSXML2.IXMLDOMText
System.Xml.XmlCharacterData
MSXML2.tagDOMNodeType
System.Xml.XmlNodeType
MSXML2.IXMLDOMCharacterData
System.Xml.XmlCharacterData
MSXML2.IXMLDOMDocumentFragment
System.Xml.XmlDocumentFragment
MSXML2.IXMLDOMComment
System.Xml.XmlComment
MSXML2.IXMLDOMEntity
System.Xml.XmlEntity
MSXML2.IXMLDOMEntityReference
System.Xml.XmlEntityReference
MSXML2.IXMLDOMImplementation
System.Xml.XmlImplementation
MSXML2.IXMLDOMNotation
System.Xml.XmlNotation
MSXML2.IXMLDOMProcessingInstruction
System.Xml.XmlProcessingInstruction
MSXML2.IXMLDOMDocumentType
System.Xml.XmlDocumentType
MSXML2.FreeThreadedDOMDocument
System.Xml.XmlDocument
MSXML2.FreeThreadedDOMDocument40
System.Xml.XmlDocument
MSXML2.DOMDocument40
System.Xml.XmlDocument
Original VB6 code:
Private Sub foo()
Dim doc As MSXML2.DOMDocument
Dim node As MSXML2.IXMLDOMNode
Dim newnode As MSXML2.IXMLDOMNode
Dim newclonednode As MSXML2.IXMLDOMNode
Set newnode = doc.appendChild(node)
Set newclonednode = doc.cloneNode(True)
newnode.appendChild newclonednode
Dim n As MSXML2.IXMLDOMNode
Dim theNodeList As MSXML2.IXMLDOMNodeList
Set theNodeList = doc.selectNodes("Norway")
For Each n In theNodeList
n.Attributes(0).nodeValue = "Norway"
Next n
End Sub
Partial Class Form1
...
Private Sub foo()
Dim doc As XmlDocument
Dim node As XmlNode
Dim newnode As XmlNode = doc.AppendChild(node)
Dim newclonednode As XmlNode = doc.CloneNode(True)
newnode.AppendChild(newclonednode)
Dim theNodeList As XmlNodeList = doc.SelectNodes("Norway")
For Each n As XmlNode In theNodeList
n.Attributes.Item(0).Value = "Norway"
Next n
End Sub
9.2. To COM Interop
This feature will take the legacy COM control and create an interoperability code wrapper to make it visible from the managed code. This means the control's functionality will remain the same since it will use the same binary, but the resulting application will depend on the legacy control.
Original VB6 code:
Private Sub foo()
Dim doc As MSXML2.DOMDocument
Dim node As MSXML2.IXMLDOMNode
Dim newnode As MSXML2.IXMLDOMNode
Dim newclonednode As MSXML2.IXMLDOMNode
Set newnode = doc.appendChild(node)
Set newclonednode = doc.cloneNode(True)
newnode.appendChild newclonednode
Dim n As MSXML2.IXMLDOMNode
Dim theNodeList As MSXML2.IXMLDOMNodeList
Set theNodeList = doc.selectNodes("Norway")
For Each n In theNodeList
n.Attributes(0).nodeValue = "Norway"
Next n
End Sub
Partial Class Form1
...
Private Sub foo()
Dim doc As MSXML2.DOMDocument
Dim node As MSXML2.IXMLDOMNode
Dim newnode As MSXML2.IXMLDOMNode = doc.appendChild(node)
Dim newclonednode As MSXML2.IXMLDOMNode = doc.cloneNode(True)
newnode.appendChild(newclonednode)
Dim theNodeList As MSXML2.IXMLDOMNodeList = doc.selectNodes("Norway")
For Each n As MSXML2.IXMLDOMNode In theNodeList
'UPGRADE_WARNING: (1037) Couldnt resolve default property of object n.Attributes().nodeValue.'
n.attributes(0).nodeValue = "Norway"
Next n
End Sub
...
10. RichTextBox
10.1. To System.Windows.Forms.RichTextBox
Convert RichTextBox to a .NET component control.
By using this option the converted application will not have any reference to the COM Component.
Class
Maps to
RichTextLib.RichTextBox
System.Windows.Forms.RichTextBox
RichTextLib.AppearanceConstants
System.Windows.Forms.BorderStyle
RichTextLib.BorderStyleConstants
System.Windows.Forms.BorderStyle
RichTextLib.ScrollBarsConstants
System.Windows.Forms.RichTextBoxScrollBars
RichTextLib.FindConstants
System.Windows.Forms.RichTextBoxFinds
RichTextLib.LoadSaveConstants
System.Windows.Forms.RichTextBoxStreamType
RichTextLib.SelAlignmentConstants
System.Windows.Forms.HorizontalAlignment
RichTextLib.MousePointerConstants
System.Windows.Forms.Cursor
Original VB6 code:
Begin VB.Form Form1
...
Begin RichTextLib.RichTextBox RichTextBox1
Height = 615
Left = 120
TabIndex = 0
Top = 120
Width = 2175
_ExtentX = 3836
_ExtentY = 1085
_Version = 393217
TextRTF = $"Form1.frx":0000
End
...
C# code:
partialclassForm1{ ...publicSystem.Windows.Forms.RichTextBox RichTextBox1; ...privatevoidInitializeComponent() {...this.RichTextBox1=newSystem.Windows.Forms.RichTextBox();this.RichTextBox1.BorderStyle=System.Windows.Forms.BorderStyle.FixedSingle;this.RichTextBox1.Font=newSystem.Drawing.Font("Microsoft Sans Serif",8f,System.Drawing.FontStyle.Regular,System.Drawing.GraphicsUnit.Point,0);this.RichTextBox1.Location=newSystem.Drawing.Point(8,8);this.RichTextBox1.Name="RichTextBox1";this.RichTextBox1.Rtf=resources.GetString("RichTextBox1.TextRTF");this.RichTextBox1.ScrollBars=System.Windows.Forms.RichTextBoxScrollBars.None;this.RichTextBox1.Size=newSystem.Drawing.Size(145,41);this.RichTextBox1.TabIndex=0;... }}
VB.NET code:
Partial Class Form1
...
Public WithEvents RichTextBox1 As System.Windows.Forms.RichTextBox
...
Private Sub InitializeComponent()
...
Me.RichTextBox1 = New System.Windows.Forms.RichTextBox
Me.RichTextBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
Me.RichTextBox1.Font = New System.Drawing.Font("Microsoft Sans Serif", 8!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0)
Me.RichTextBox1.Location = New System.Drawing.Point(8, 8)
Me.RichTextBox1.Name = "RichTextBox1"
Me.RichTextBox1.Rtf = resources.GetString("RichTextBox1.TextRTF")
Me.RichTextBox1.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.None
Me.RichTextBox1.Size = New System.Drawing.Size(145, 41)
Me.RichTextBox1.TabIndex = 0
...
10.2. To COM Interop
This feature will take the legacy COM control and create an interoperability code wrapper to make it visible from the managed code. This means the control's functionality will remain the same since it will use the same binary, but the resulting application will depend on the legacy control.
Original VB6 code:
Begin VB.Form Form1
...
Begin RichTextLib.RichTextBox RichTextBox1
Height = 615
Left = 120
TabIndex = 0
Top = 120
Width = 2175
_ExtentX = 3836
_ExtentY = 1085
_Version = 393217
TextRTF = $"Form1.frx":0000
End
...
This option converts the "Scripting.Dictionary" class to a .NET "OrderedDictionary". Members are also mapped to OrderedDictionary members.
General Description:
An OrderedDictionary is a dictionary (hash table) that preserves the order (as VB6 does) in which the keys are inserted. A regular dictionary does not track the insertion order.
Original VB6 code:
Public Sub Foo(dict As Scripting.Dictionary)
Call dict.Add("A", 1): Call dict.Add("B", 2): Call dict.Add("C", 3)
If dict.Exists("C") Then
MsgBox dict.item("C")
End If
For Each value In dict.keys
MsgBox value 'prints A B C'
Next
For Each value In dict.Items
MsgBox value 'prints 1 2 3'
Next
End Sub
C# code:
publicstaticvoidFoo(OrderedDictionary dict){dict.Add("A",1); dict.Add("B",2); dict.Add("C",3);if (dict.Contains("C")) {MessageBox.Show(Convert.ToString(dict["C"])); }foreach (object value indict.Keys) {MessageBox.Show(Convert.ToString(value)); //prints A B C }foreach (object value indict.Values) {MessageBox.Show(Convert.ToString(value)); //prints 1 2 3 }}
VB.NET code:
Public Sub Foo(ByVal dict As OrderedDictionary)
dict.Add("A", 1) : dict.Add("B", 2) : dict.Add("C", 3)
If dict.Contains("C") Then
MessageBox.Show(CStr(dict.Item("C")))
End If
For Each value As Object In dict.Keys
MessageBox.Show(CStr(value), My.Application.Info.Title) 'prints A B C'
Next value
For Each value As Object In dict.Values
MessageBox.Show(CStr(value), My.Application.Info.Title) 'prints 1 2 3'
Next value
End Sub
11.2. To COM Interop
This feature will take the legacy COM control and create an interoperability code wrapper to make it visible from the managed code. This means the control's functionality will remain the same since it will use the same binary, but the resulting application will depend on the legacy control.
Original VB6 code:
Public Sub Foo(dict As Scripting.Dictionary)
Call dict.Add("A", 1): Call dict.Add("B", 2): Call dict.Add("C", 3)
If dict.Exists("C") Then
MsgBox dict.item("C")
End If
For Each value In dict.keys
MsgBox value 'prints A B C'
Next
For Each value In dict.Items
MsgBox value 'prints 1 2 3'
Next
End Sub
C# code:
publicstaticvoidFoo(Scripting.Dictionary dict){object tempRefParam ="A"; object tempRefParam2 =1;dict.Add(ref tempRefParam,ref tempRefParam2);object tempRefParam3 ="B"; object tempRefParam4 =2;dict.Add(ref tempRefParam3,ref tempRefParam4);object tempRefParam5 ="C"; object tempRefParam6 =3;dict.Add(ref tempRefParam5,ref tempRefParam6);object tempRefParam7 ="C";if (dict.Exists(ref tempRefParam7)) {object tempRefParam8 ="C";MessageBox.Show(Convert.ToString(dict.get_Item(ref tempRefParam8))); }foreach (object value in (System.Collections.IEnumerable) dict.Keys()) {MessageBox.Show(Convert.ToString(value)); //prints A B C }foreach (object value in (System.Collections.IEnumerable) dict.Items()) {MessageBox.Show(Convert.ToString(value)); //prints 1 2 3 }}
VB.NET code:
Public Sub Foo(ByVal dict As Scripting.Dictionary)
dict.Add("A", 1) : dict.Add("B", 2) : dict.Add("C", 3)
If dict.Exists("C") Then
MessageBox.Show(CStr(dict.Item("C")))
End If
For Each value As Object In dict.Keys()
MessageBox.Show(CStr(value)) 'prints A B C'
Next value
For Each value As Object In dict.Items()
MessageBox.Show(CStr(value)) 'prints 1 2 3'
Next value
End Sub
12. SHDocVw
Microsoft Internet Controls Library
12.1. To System.Windows.Forms.WebBrowser
Convert the controls and classes contained in the shdocvw.dll to .NET Native classes.
General Description:
The Microsoft Internet Controls (SHDocVw) is a set of controls and classes that enable building web/DHTML applications in Visual Basic 6. WebBrowser and InternetExplorer are controls of this library.
Class
Maps to
WebBrowser
System.Windows.Forms.WebBrowser
SecureLockIconConstants
System.Windows.Forms.WebBrowserEncryptionLevel
tagREADYSTATE
System.Windows.Forms.WebBrowserReadyState
InternetExplorer
System.Windows.Forms.WebBrowser
Original VB6 code:
Private Sub Command1_Click() 'Go Back Button'
WebBrowser1.GoBack() 'Go Back'
End Sub
Private Sub Command2_Click() 'Go Forward Button'
WebBrowser1.GoForward() 'Go Forward'
End Sub
Private Sub Form_Load()
WebBrowser1.Navigate("www.artinsoft.com")
End Sub
Private Sub WebBrowser1_CommandStateChange(ByVal Command As Long, ByVal Enable As Boolean)
Select Case Command
Case 1 'Forward'
Command2.Enabled = True
Case 2 'Back'
Command1.Enabled = True
End Select
End Sub
C# code:
privatevoidCommand1_Click(Object eventSender,EventArgs eventArgs) //Go Back Button{WebBrowser1.GoBack(); //Go Back}privatevoidCommand2_Click(Object eventSender,EventArgs eventArgs) //Go Forward Button{WebBrowser1.GoForward(); //Go Forward}//UPGRADE_WARNING: (2080) Form_Load event was upgraded to Form_Load event and has a new behavior.privatevoidForm1_Load(Object eventSender,EventArgs eventArgs){WebBrowser1.Navigate("www.artinsoft.com");}//UPGRADE_WARNING: (2050) SHDocVw.WebBrowser Event WebBrowser1.CommandStateChange was not upgraded.privatevoidWebBrowser1_CommandStateChange(int Command,bool Enable){switch(Command) {case1://Forward Command2.Enabled=true; break;case2://Back Command1.Enabled=true; break; } }}
VB.NET code:
Private Sub Command1_Click(ByVal eventSender As Object, ByVal eventArgs As EventArgs) Handles Command1.Click 'Go Back Button'
WebBrowser1.GoBack() 'Go Back'
End Sub
Private Sub Command2_Click(ByVal eventSender As Object, ByVal eventArgs As EventArgs) Handles Command2.Click 'Go Forward Button'
WebBrowser1.GoForward() 'Go Forward'
End Sub
'UPGRADE_WARNING: (2080) Form_Load event was upgraded to Form_Load event and has a new behavior.'
Private Sub Form1_Load(ByVal eventSender As Object, ByVal eventArgs As EventArgs) Handles MyBase.Load
WebBrowser1.Navigate("www.artinsoft.com")
End Sub
'UPGRADE_WARNING: (2050) SHDocVw.WebBrowser Event WebBrowser1.CommandStateChange was not upgraded.'
Private Sub WebBrowser1_CommandStateChange(ByVal Command As Integer, ByVal Enable As Boolean)
Select Case Command
Case 1 'Forward'
Command2.Enabled = True
Case 2 'Back'
Command1.Enabled = True
End Select
End Sub
12.2. To COM Interop
This feature will take the legacy COM control and create an interoperability code wrapper to make it visible from the managed code. This means the control's functionality will remain the same since it will use the same binary, but the resulting application will depend on the legacy control.
Original VB6 code:
Private Sub Command1_Click() 'Go Back Button'
WebBrowser1.GoBack() 'Go Back'
End Sub
Private Sub Command2_Click() 'Go Forward Button'
WebBrowser1.GoForward() 'Go Forward'
End Sub
Private Sub Form_Load()
WebBrowser1.Navigate("www.artinsoft.com")
End Sub
Private Sub WebBrowser1_CommandStateChange(ByVal Command As Long, ByVal Enable As Boolean)
Select Case Command
Case 1 'Forward'
Command2.Enabled = True
Case 2 'Back'
Command1.Enabled = True
End Select
End Sub
C# code:
privatevoidCommand1_Click(Object eventSender,EventArgs eventArgs) //Go Back Button{WebBrowser1.GoBack(); //Go Back}privatevoidCommand2_Click(Object eventSender,EventArgs eventArgs) //Go Forward Button{ WebBrowser1.GoForward(); //Go Forward}//UPGRADE_WARNING: (2080) Form_Load event was upgraded to Form_Load event and has a new behavior.privatevoidForm1_Load(Object eventSender,EventArgs eventArgs){WebBrowser1.Navigate(newURI("www.artinsoft.com"));}//UPGRADE_WARNING: (2050) SHDocVw.WebBrowser Event WebBrowser1.CommandStateChange was not upgraded.privatevoidWebBrowser1_CommandStateChange(int Command,bool Enable){switch(Command) {case1://Forward Command2.Enabled=true; break;case2://Back Command1.Enabled=true; break; }}
VB.NET code:
Private Sub Command1_Click(ByVal eventSender As Object, ByVal eventArgs As EventArgs) Handles Command1.Click 'Go Back Button'
WebBrowser1.GoBack() 'Go Back'
End Sub
Private Sub Command2_Click(ByVal eventSender As Object, ByVal eventArgs As EventArgs) Handles Command2.Click 'Go Forward Button'
WebBrowser1.GoForward() 'Go Forward'
End Sub
'UPGRADE_WARNING: (2080) Form_Load event was upgraded to Form_Load event and has a new behavior.'
Private Sub Form1_Load(ByVal eventSender As Object, ByVal eventArgs As EventArgs) Handles MyBase.Load
WebBrowser1.Navigate(New URI("www.artinsoft.com"))
End Sub
'UPGRADE_WARNING: (2050) SHDocVw.WebBrowser Event WebBrowser1.CommandStateChange was not upgraded.'
Private Sub WebBrowser1_CommandStateChange(ByVal Command As Integer, ByVal Enable As Boolean)
Select Case Command
Case 1 'Forward'
Command2.Enabled = True
Case 2 'Back'
Command1.Enabled = True
End Select
End Sub
13. Shell32
13.1. To System.Diagnostics Methods
Convert the API calls of Shell32 to their equivalents in System.Diagnostics.
Operation
Purpose
Edit
Launches an editor and opens the file for editing.
Explore
Explores the folder listed in the file parameter.
Find
Starts the find utility at the specified directory.
Open
Opens the file using the appropriate default application.
It can also executes processes and applications.
Print
Prints the file.
Original VB6 code:
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
(ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, _
ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
ShellExecute 0, "open", "C:\file.ext", Empty, Empty, 1
This optional feature will take the API declaration and create an interoperability code wrapper to make it visible from the managed code. This means the call’s functionality will remain the same since it will use the same API but the resulting application will depend on the API binary file.
Original VB6 code:
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _ (ByVal hWnd As Long, ByVal lpOperation AsString, ByVal lpFile AsString, _ ByVal lpParameters AsString, ByVal lpDirectory AsString, ByVal nShowCmd As Long) As LongShellExecute 0,"open","C:\file.ext", Empty, Empty,1
The VB Script RegExp class compares strings with specific text patterns known as regular expressions.
14.1. To System.Text.RegularExpressions and helpers
This optional feature allows the VBUC to convert VB Script RegExp to System.Text.RegularExpressions library and helpers.
This option converts VB Script RegExp by using helper classes, achieving very high automation levels and a similar VB6 behavior.
By using this option the converted application will not have any references to the COM Component.
Class
Maps to
VBScript_RegExp_55.Regexp
UpgradeHelpers.Utils.ScriptRegexHelper
VBScript_RegExp_55.MatchCollection
System.Text.RegularExpressions.MatchCollection
VBScript_RegExp_55.Match
System.Text.RegularExpressions.Match
Original VB6 Code:
Private Sub cmdSearch_Click()
Dim strInput As String
Dim regex As RegExp
Dim matches As MatchCollection
Dim match As match
strInput = txtInput.text
'Create Regex object
Set regex = New RegExp
regex.Global = True
regex.IgnoreCase = True
regex.Pattern = "(\w+)"
'Search all coincidences
Set matches = regex.Execute(strInput)
'Show coincidences found
Dim i As Integer
For Each match In matches
MsgBox "Result " & i + 1 & ": " & match.Value
i = i + 1
Next match
End Sub
C# code:
privatevoidcmdSearch_Click(Object eventSender,EventArgs eventArgs){Match match =null;string strInput =txtInput.Text; //Create Regex objectScriptRegexHelper regex =newScriptRegexHelper(); //UPGRADE_ISSUE: (2064) VBScript_RegExp_55.RegExp property regex.Global was not upgraded. More Information: https://docs.mobilize.net/vbuc/ewis#2064regex.setGlobal(true);regex.IgnoreCase=true;regex.Pattern="(\\w+)"; //Search all coincidencesMatchCollection matches = (MatchCollection) regex.Execute(strInput); //Show coincidences foundint i =0;foreach (Match matchIterator in matches) { match = matchIterator;MessageBox.Show($"Result {(i +1).ToString()}: {match.Value}",AssemblyHelper.GetTitle(System.Reflection.Assembly.GetExecutingAssembly())); i++; //match match =default(Match); }}
VB.NET code:
Private Sub cmdSearch_Click(ByVal eventSender As Object, ByVal eventArgs As EventArgs) Handles cmdSearch.Click
Dim match As Match
Dim strInput As String = txtInput.Text
'Create Regex object
Dim regex As New ScriptRegexHelper()
'UPGRADE_ISSUE: (2064) VBScript_RegExp_55.RegExp property regex.Global was not upgraded. More Information: https://docs.mobilize.net/vbuc/ewis#2064
regex.setGlobal(True)
regex.IgnoreCase = True
regex.Pattern = "(\w+)"
'Search all coincidences
Dim matches As MatchCollection = regex.Execute(strInput)
'Show coincidences found
Dim i As Integer
For Each matchIterator As Match In matches
match = matchIterator
MessageBox.Show("Result " & i + 1 & ": " & match.Value, My.Application.Info.Title)
i += 1
'match
match = CType(Nothing, Match)
Next matchIterator
End Sub
14.2. To COM Interop
This feature will take the legacy COM control and create an interoperability code wrapper to make it visible from the managed code. This means the control's functionality will remain the same since it will use the same binary, but the resulting application will depend on the legacy control.
Original VB6 Code:
Private Sub cmdSearch_Click()
Dim strInput As String
Dim regex As RegExp
Dim matches As MatchCollection
Dim match As match
strInput = txtInput.text
'Create Regex object
Set regex = New RegExp
regex.Global = True
regex.IgnoreCase = True
regex.Pattern = "(\w+)"
'Search all coincidences
Set matches = regex.Execute(strInput)
'Show coincidences found
Dim i As Integer
For Each match In matches
MsgBox "Result " & i + 1 & ": " & match.Value
i = i + 1
Next match
End Sub
C# code:
privatevoidcmdSearch_Click(Object eventSender,EventArgs eventArgs){VBScript_RegExp_55.Match match =null;string strInput =txtInput.Text; //Create Regex objectVBScript_RegExp_55.RegExp regex =newVBScript_RegExp_55.RegExp();regex.Global=true;regex.IgnoreCase=true;regex.Pattern="(\\w+)"; //Search all coincidencesVBScript_RegExp_55.MatchCollection matches = (VBScript_RegExp_55.MatchCollection) regex.Execute(strInput); //Show coincidences foundint i =0;foreach (VBScript_RegExp_55.Match matchIterator in matches) { match = matchIterator;MessageBox.Show($"Result {(i +1).ToString()}: {match.Value}",AssemblyHelper.GetTitle(System.Reflection.Assembly.GetExecutingAssembly())); i++; //match match =default(VBScript_RegExp_55.Match); }}
VB.NET Code:
Private Sub cmdSearch_Click(ByVal eventSender As Object, ByVal eventArgs As EventArgs) Handles cmdSearch.Click
Dim match As VBScript_RegExp_55.Match
Dim strInput As String = txtInput.Text
'Create Regex object
Dim regex As New VBScript_RegExp_55.RegExp()
regex.Global = True
regex.IgnoreCase = True
regex.Pattern = "(\w+)"
'Search all coincidences
Dim matches As VBScript_RegExp_55.MatchCollection = regex.Execute(strInput)
'Show coincidences found
Dim i As Integer
For Each matchIterator As VBScript_RegExp_55.Match In matches
match = matchIterator
MessageBox.Show("Result " & i + 1 & ": " & match.Value, My.Application.Info.Title)
i += 1
'match
match = CType(Nothing, VBScript_RegExp_55.Match)
Next matchIterator
End Sub