This section provides different options to upgrade other controls that are common in VB6 applications and that don’t fit in any of the other sections.
As with the previous options, all these components have two alternatives when upgrading them to .NET, one is to upgrade using COM Interop and the second one is to use .NET components.
1. Accusoft
1.1. To Accusoft .NET Version
General Description:
This solution converts the Accusoft VB6 library to the Accusoft.NET component.
Class
Maps to
AccusoftISISXpress7.ISISXpress
Accusoft.ISISXpressSdk.IsisXpress
AccusoftISISXpress7.ISX_SaveFileType
Accusoft.ISISXpressSdk.FileTypeInfo
AccusoftISISXpress7.ISX_ScanSetting
Accusoft.ISISXpressSdk.ScanSettingInfo
AccusoftISISXpress7.ISX_SetupOptions
Accusoft.ISISXpressSdk.SetupOptions
AccusoftImagXpress13.ImagXpress
Accusoft.ImagXpressSdk.ImageXView
AccusoftImagXpress13.enumAutoSize
Accusoft.ImagXpressSdk.AutoResizeType
AccusoftImagXpress13.enumZoomFit
Accusoft.ImagXpressSdk.ZoomToFitType
Original VB6 code:
Begin AccusoftImagXpress13Ctl.ImagXpress ImagXpress1
...
End
Begin AccusoftISISXpress7Ctl.ISISXpress ISISXpress1
...
End
Private Sub Command2_Click()
Me.ISISXpress1.CreateDib = True
Me.ISISXpress1.CreateFiles = True
Dim driver As String
Dim scanner As String
Dim r As String
r = Me.ISISXpress1.Root
Me.ISISXpress1.Cancel
Me.ISISXpress1.Cancel True
Me.ISISXpress1.Cancel False
Me.ISISXpress1.CancelImmediate
End Sub
Private Sub Form_Load()
Me.ImagXpress1.FileName = "Tulips.jpg"
Me.ImagXpress1.ZoomFactor = 1
Me.ImagXpress1.ZoomToFit ZOOMFIT_BEST
Me.ImagXpress1.DrawTextString 100, 100, "This is a sample", 0
Dim n As Integer
n = ImagXpress1.PageNbr
MsgBox n
n = ImagXpress1.Pages
MsgBox n
ImagXpress1.AutoSize = ISIZE_BestFit
MsgBox ImagXpress1.FileName
ImagXpress1.SaveFile
End Sub
Private Sub ISISXpress1_FeederEmpty(ByVal PageNumber As Long, StopScan As Boolean)
MsgBox PageNumber
End Sub
C# code:
public Accusoft.ImagXpressSdk.ImageXView ImagXpress1;
public Accusoft.ImagXpressSdk.ImagXpress ImagXpress1_Component;
public Accusoft.ISISXpressSdk.IsisXpress ISISXpress1;
...
this.ImagXpress1 = new Accusoft.ImagXpressSdk.ImageXView();
this.ImagXpress1_Component = new Accusoft.ImagXpressSdk.ImagXpress();
this.ISISXpress1 = new Accusoft.ISISXpressSdk.IsisXpress();
...
private void Command2_Click(Object eventSender, EventArgs eventArgs)
{
this.ISISXpress1.Output.CreateDib = true;
this.ISISXpress1.Output.CreateFiles = true;
string driver = "";
string scanner = "";
string r = this.ISISXpress1.Output.Root;
this.ISISXpress1.Scanner.Cancel();
this.ISISXpress1.Scanner.Cancel(true);
this.ISISXpress1.Scanner.Cancel(false);
this.ISISXpress1.Scanner.Cancel(true);
}
//UPGRADE_WARNING: (2080) Form_Load event was upgraded to Form_Load method and has a new behavior. private void Form_Load()
{
this.ImagXpress1.Image = Accusoft.ImagXpressSdk.ImageX.FromFile(ImagXpress1_Component, "Tulips.jpg");
this.ImagXpress1.ZoomFactor = 1;
this.ImagXpress1.ZoomToFit(Accusoft.ImagXpressSdk.ZoomToFitType.FitBest);
Graphics graphics = this.ImagXpress1.Image.GetGraphics();
graphics.DrawString("This is a sample", new Font(SystemFonts.DefaultFont.Name, SystemFonts.DefaultFont.Size), new SolidBrush(Color.Black), 100, 100);
this.ImagXpress1.Image.ReleaseGraphics(true);
int n = ImagXpress1.Image.Page;
MessageBox.Show(n.ToString(), AssemblyHelper.GetTitle(System.Reflection.Assembly.GetExecutingAssembly()));
n = ImagXpress1.Image.PageCount;
MessageBox.Show(n.ToString(), AssemblyHelper.GetTitle(System.Reflection.Assembly.GetExecutingAssembly()));
ImagXpress1.AutoResize = Accusoft.ImagXpressSdk.AutoResizeType.BestFit;
MessageBox.Show(ImagXpress1.Image.Filename, AssemblyHelper.GetTitle(System.Reflection.Assembly.GetExecutingAssembly()));
//UPGRADE_ISSUE: (2064) AccusoftImagXpress13.ImagXpress method ImagXpress1.SaveFile was not upgraded.
ImagXpress1.SaveFile();
}
private void ISISXpress1_FeederEmpty(object eventSender, Accusoft.ISISXpressSdk.FeederEmptyEventArgs eventArgs)
{
int PageNumber = eventArgs.PageNumber;
bool StopScan = eventArgs.StopScan;
MessageBox.Show(PageNumber.ToString(), AssemblyHelper.GetTitle(System.Reflection.Assembly.GetExecutingAssembly()));
}
VB.NET code:
Public WithEvents ImagXpress1 As Accusoft.ImagXpressSdk.ImageXView
Public WithEvents ImagXpress1_Component As Accusoft.ImagXpressSdk.ImagXpress
Public WithEvents ISISXpress1 As Accusoft.ISISXpressSdk.IsisXpress
...
Me.ImagXpress1 = New Accusoft.ImagXpressSdk.ImageXView()
Me.ImagXpress1_Component = New Accusoft.ImagXpressSdk.ImagXpress()
Me.ISISXpress1 = New Accusoft.ISISXpressSdk.IsisXpress()
...
Private Sub Command2_Click(ByVal eventSender As Object, ByVal eventArgs As EventArgs) Handles Command2.Click
Me.ISISXpress1.Output.CreateDib = True
Me.ISISXpress1.Output.CreateFiles = True
Dim driver As String = "", scanner As String = ""
Dim r As String = Me.ISISXpress1.Output.Root
Me.ISISXpress1.Scanner.Cancel()
Me.ISISXpress1.Scanner.Cancel(True)
Me.ISISXpress1.Scanner.Cancel(False)
Me.ISISXpress1.Scanner.Cancel(True)
End Sub
'UPGRADE_WARNING: (2080) Form_Load event was upgraded to Form_Load method and has a new behavior.'
Private Sub Form_Load()
Me.ImagXpress1.Image = Accusoft.ImagXpressSdk.ImageX.FromFile(ImagXpress1_Component, "Tulips.jpg")
Me.ImagXpress1.ZoomFactor = 1
Me.ImagXpress1.ZoomToFit(Accusoft.ImagXpressSdk.ZoomToFitType.FitBest)
Dim graphics As Graphics = Me.ImagXpress1.Image.GetGraphics()
graphics.DrawString("This is a sample", New Font(SystemFonts.DefaultFont.Name, SystemFonts.DefaultFont.Size), New SolidBrush(Color.Black), 100, 100)
Me.ImagXpress1.Image.ReleaseGraphics(True)
Dim n As Integer = ImagXpress1.Image.Page
MessageBox.Show(CStr(n), My.Application.Info.Title)
n = ImagXpress1.Image.PageCount
MessageBox.Show(CStr(n), My.Application.Info.Title)
ImagXpress1.AutoResize = Accusoft.ImagXpressSdk.AutoResizeType.BestFit
MessageBox.Show(ImagXpress1.Image.Filename, My.Application.Info.Title)
'UPGRADE_ISSUE: (2064) AccusoftImagXpress13.ImagXpress method ImagXpress1.SaveFile was not upgraded.'
ImagXpress1.SaveFile()
End Sub
Private Sub ISISXpress1_FeederEmpty(ByVal eventSender As object, ByVal eventArgs As Accusoft.ISISXpressSdk.FeederEmptyEventArgs) Handles ISISXpress1.FeederEmpty
Dim PageNumber As Integer = eventArgs.PageNumber
Dim StopScan As Boolean = eventArgs.StopScan
MessageBox.Show(CStr(PageNumber), My.Application.Info.Title)
End Sub
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 AccusoftImagXpress13Ctl.ImagXpress ImagXpress1
...
End
Begin AccusoftISISXpress7Ctl.ISISXpress ISISXpress1
...
End
Private Sub Command2_Click()
Me.ISISXpress1.CreateDib = True
Me.ISISXpress1.CreateFiles = True
Dim driver As String
Dim scanner As String
Dim r As String
r = Me.ISISXpress1.Root
Me.ISISXpress1.Cancel
Me.ISISXpress1.Cancel True
Me.ISISXpress1.Cancel False
Me.ISISXpress1.CancelImmediate
End Sub
Private Sub Form_Load()
Me.ImagXpress1.FileName = "Tulips.jpg"
Me.ImagXpress1.ZoomFactor = 1
Me.ImagXpress1.ZoomToFit ZOOMFIT_BEST
Me.ImagXpress1.DrawTextString 100, 100, "This is a sample", 0
Dim n As Integer
n = ImagXpress1.PageNbr
MsgBox n
n = ImagXpress1.Pages
MsgBox n
ImagXpress1.AutoSize = ISIZE_BestFit
MsgBox ImagXpress1.FileName
ImagXpress1.SaveFile
End Sub
Private Sub ISISXpress1_FeederEmpty(ByVal PageNumber As Long, StopScan As Boolean)
MsgBox PageNumber
End Sub
C# code:
public AxAccusoftImagXpress13.AxImagXpress ImagXpress1;
public AxAccusoftISISXpress7.AxISISXpress ISISXpress1;
...
this.ImagXpress1 = new AxAccusoftImagXpress13.AxImagXpress();
this.ISISXpress1 = new AxAccusoftISISXpress7.AxISISXpress();
...
private void Command2_Click(Object eventSender, EventArgs eventArgs)
{
this.ISISXpress1.CreateDib = true;
this.ISISXpress1.CreateFiles = true;
string driver = "";
string scanner = "";
string r = this.ISISXpress1.Root;
//UPGRADE_ISSUE: (2064) AccusoftISISXpress7.ISISXpress method ISISXpress1.Cancel was not upgraded.
this.ISISXpress1.Cancel(true);
//UPGRADE_ISSUE: (2064) AccusoftISISXpress7.ISISXpress method ISISXpress1.Cancel was not upgraded.
this.ISISXpress1.Cancel(true);
//UPGRADE_ISSUE: (2064) AccusoftISISXpress7.ISISXpress method ISISXpress1.Cancel was not upgraded.
this.ISISXpress1.Cancel(false);
this.ISISXpress1.CancelImmediate();
}
//UPGRADE_WARNING: (2080) Form_Load event was upgraded to Form_Load method and has a new behavior. private void Form_Load()
{
this.ImagXpress1.FileName = "Tulips.jpg";
this.ImagXpress1.ZoomFactor = 1;
this.ImagXpress1.ZoomToFit(AccusoftImagXpress13.enumZoomFit.ZOOMFIT_BEST);
this.ImagXpress1.DrawTextString(100, 100, "This is a sample", Convert.ToUInt32(0));
int n = ImagXpress1.PageNbr;
MessageBox.Show(n.ToString(), AssemblyHelper.GetTitle(System.Reflection.Assembly.GetExecutingAssembly()));
n = ImagXpress1.Pages;
MessageBox.Show(n.ToString(), AssemblyHelper.GetTitle(System.Reflection.Assembly.GetExecutingAssembly()));
ImagXpress1.CtlAutoSize = AccusoftImagXpress13.enumAutoSize.ISIZE_BestFit;
MessageBox.Show(ImagXpress1.FileName, AssemblyHelper.GetTitle(System.Reflection.Assembly.GetExecutingAssembly()));
ImagXpress1.SaveFile();
}
private void ISISXpress1_FeederEmpty(Object eventSender, AxAccusoftISISXpress7._IISISXpressEvents_FeederEmptyEvent eventArgs)
{
MessageBox.Show(eventArgs.pageNumber.ToString(), AssemblyHelper.GetTitle(System.Reflection.Assembly.GetExecutingAssembly()));
}
VB.NET code:
Public WithEvents ImagXpress1 As AxAccusoftImagXpress13.AxImagXpress
Public WithEvents ISISXpress1 As AxAccusoftISISXpress7.AxISISXpress
...
Me.ImagXpress1 = New AxAccusoftImagXpress13.AxImagXpress()
Me.ISISXpress1 = New AxAccusoftISISXpress7.AxISISXpress()
...
Private Sub Command2_Click(ByVal eventSender As Object, ByVal eventArgs As EventArgs) Handles Command2.Click
Me.ISISXpress1.CreateDib = True
Me.ISISXpress1.CreateFiles = True
Dim driver As String = "", scanner As String = ""
Dim r As String = Me.ISISXpress1.Root
'UPGRADE_ISSUE: (2064) AccusoftISISXpress7.ISISXpress method ISISXpress1.Cancel was not upgraded.'
Me.ISISXpress1.Cancel()
'UPGRADE_ISSUE: (2064) AccusoftISISXpress7.ISISXpress method ISISXpress1.Cancel was not upgraded.'
Me.ISISXpress1.Cancel(True)
'UPGRADE_ISSUE: (2064) AccusoftISISXpress7.ISISXpress method ISISXpress1.Cancel was not upgraded.'
Me.ISISXpress1.Cancel(False)
Me.ISISXpress1.CancelImmediate()
End Sub
'UPGRADE_WARNING: (2080) Form_Load event was upgraded to Form_Load method and has a new behavior. Private Sub Form_Load()'
Me.ImagXpress1.FileName = "Tulips.jpg"
Me.ImagXpress1.ZoomFactor = 1
Me.ImagXpress1.ZoomToFit(AccusoftImagXpress13.enumZoomFit.ZOOMFIT_BEST)
Me.ImagXpress1.DrawTextString(100, 100, "This is a sample", Convert.ToUInt32(0))
Dim n As Integer = ImagXpress1.PageNbr
MessageBox.Show(CStr(n), My.Application.Info.Title)
n = ImagXpress1.Pages
MessageBox.Show(CStr(n), My.Application.Info.Title)
ImagXpress1.CtlAutoSize = AccusoftImagXpress13.enumAutoSize.ISIZE_BestFit
MessageBox.Show(ImagXpress1.FileName, My.Application.Info.Title)
ImagXpress1.SaveFile()
End Sub
Private Sub ISISXpress1_FeederEmpty(ByVal eventSender As Object, ByVal eventArgs As AxAccusoftISISXpress7._IISISXpressEvents_FeederEmptyEvent) Handles ISISXpress1.FeederEmpty
MessageBox.Show(CStr(eventArgs.pageNumber), My.Application.Info.Title)
End Sub
2. ActiveBarLibrary
2.1. To DevExpress.XtraBars
Convert ActiveBar2Library.ActiveBar2 classes to DevExpress.XtraBars.BarManager.
By using this option the converted application will not have any reference to the COM Component.
Private Sub Form_Load()
Dim X1 As Color = Me.ActiveBarHelper1.GetForeColor(Me.ActiveBar1)
Dim X2 As String = Me.ActiveBarHelper1.GetFont(Me.ActiveBar1).Name
Me.ActiveBar1.ShowShortcutInScreenTips = False
Me.ActiveBar1.ToolTipController.Active = True
End Sub
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:
Private Sub Form_Load()
...
X1 = Me.ActiveBar1.ForeColor
X2 = Me.ActiveBar1.Font
Me.ActiveBar1.DisplayKeysInToolTip = False
Me.ActiveBar1.DisplayToolTips = True
End Sub
Private Sub Form_Load()
Dim X1 As Color = Me.ActiveBarHelper1.GetForeColor(Me.ActiveBar1)
Dim X2 As String = Me.ActiveBarHelper1.GetFont(Me.ActiveBar1).Name
Me.ActiveBar1.ShowShortcutInScreenTips = False
Me.ActiveBar1.ToolTipController.Active = True
End Sub
3. Component One Elastic
3.1. To System.Windows.Forms.Panel
This option will port the legacy COM control into the resulting application as a System.Windows.Forms.Panel control.
By using this option the converted application will not have any reference to the COM Component.
Original VB6 code:
Begin VB.Form Form1
...
Begin C1SizerLibCtl.C1Elastic C1Elastic1
...
End
End
Private Sub Form_Load()
Dim ctl As C1Elastic
Set ctl = C1Elastic1
ctl.Align = asFill
ctl.Width = 200
ctl.Top = 3000
ctl.Enabled = False
End Sub
Partial Class Form1
...
Public WithEvents C1Elastic1 As System.Windows.Forms.Panel
...
Private Sub InitializeComponent()
...
Me.C1Elastic1 = New System.Windows.Forms.Panel()
...
Private Sub Form_Load()
Dim ctl As Panel = C1Elastic1
ctl.Dock = DockStyle.Fill
ctl.Width = 200
ctl.Top = 3000
ctl.Enabled = False
End Sub
3.2. To ComponentOne controls
This option will port the legacy COM control into the resulting application as a System.Windows.Forms.Panel control, along with a C1SizerLight control attached to the resulting form which handles the proportional resizing of all the controls in the form, including the mapped panel.
By using this option the converted application will not have any reference to the COM Component.
Original VB6 code:
Begin VB.Form Form1
...
Begin C1SizerLibCtl.C1Elastic C1Elastic1
...
End
End
Private Sub Form_Load()
Dim ctl As C1Elastic
Set ctl = C1Elastic1
ctl.Align = asFill
ctl.Width = 200
ctl.Top = 3000
ctl.Enabled = False
End Sub
Partial Class Form1
...
Public WithEvents C1Elastic1 As System.Windows.Forms.Panel
Dim c1sizerlight As C1.Win.C1Sizer.C1SizerLight
...
Private Sub InitializeComponent()
...
Me.C1Elastic1 = New System.Windows.Forms.Panel()
Me.c1sizerlight = New C1.Win.C1Sizer.C1SizerLight(Me.components)
...
Private Sub Form_Load()
Dim ctl As Panel = C1Elastic1
ctl.Dock = DockStyle.Fill
ctl.Width = 200
ctl.Top = 3000
ctl.Enabled = False
End Sub
3.3. 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()
...
X1 = Me.ActiveBar1.ForeColor
X2 = Me.ActiveBar1.Font
Me.ActiveBar1.DisplayKeysInToolTip = False
Me.ActiveBar1.DisplayToolTips = True
End Sub
Partial Class Form1
...
Public WithEvents C1Elastic1 As System.Windows.Forms.Panel
Dim c1sizerlight As C1.Win.C1Sizer.C1SizerLight
...
Private Sub InitializeComponent()
...
Me.C1Elastic1 = New System.Windows.Forms.Panel()
Me.c1sizerlight = New C1.Win.C1Sizer.C1SizerLight(Me.components)
...
Private Sub Form_Load()
Dim ctl As Panel = C1Elastic1
ctl.Dock = DockStyle.Fill
ctl.Width = 200
ctl.Top = 3000
ctl.Enabled = False
End Sub
4. Component One Tab
4.1. To System.Windows.Forms.TabControl
This option will port the legacy COM control into the resulting application as a System.Windows.Forms.TabControl control.
By using this option the converted application will not have any reference to the COM Component.
Original VB6 code:
Private Sub Form_Load()
Dim ctl As C1Tab
Dim boolValue As Boolean
Dim numTab As Integer
Set ctl = C1Tab1
ctl.Align = asFill
ctl.Width = 200
ctl.Top = 3000
ctl.Enabled = False
ctl.CurrTab = 4
ctl.AddTab "Hola2", Me.C1Tab1.NumTabs
numTab = ctl.NumTabs
boolValue = ctl.TabVisible(1)
boolValue = ctl.TabEnabled(1)
ctl.AttachPageToTab Me.Command2, Me.C1Tab1.NumTabs - 1
ctl.Move 1000, 1000, 1000, 1000
End Sub
Private Sub Form_Load()
Dim ctl As TabControl = C1Tab1
ctl.setAlign(DockStyle.Fill)
ctl.Width = 200
ctl.Top = 3000
ctl.Enabled = False
ctl.SelectedIndex = 4
ctl.TabPages.Insert(Me.C1Tab1.TabCount, "Hola2")
Dim numTab As Integer = ctl.TabCount
Dim boolValue As Boolean = ctl.TabPages(1).Visible
boolValue = ctl.TabPages(1).Enabled
ctl.TabPages(Me.C1Tab1.TabCount - 1).Controls.Add(Me.Command2)
Me.Command2.Dock = DockStyle.Fill
ctl.SetBounds(67, 67, 67, 67)
End Sub
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:
Private Sub Form_Load()
Dim ctl As C1Tab
Dim boolValue As Boolean
Dim numTab As Integer
Set ctl = C1Tab1
ctl.Align = asFill
ctl.Width = 200
ctl.Top = 3000
ctl.Enabled = False
ctl.CurrTab = 4
ctl.AddTab "Hola2", Me.C1Tab1.NumTabs
numTab = ctl.NumTabs
boolValue = ctl.TabVisible(1)
boolValue = ctl.TabEnabled(1)
ctl.AttachPageToTab Me.Command2, Me.C1Tab1.NumTabs - 1
ctl.Move 1000, 1000, 1000, 1000
End Sub
Implements ObjectControl
Private Sub ObjectControl_Activate()
End Sub
Private Function ObjectControl_CanBePooled() As Boolean
ObjectControl_CanBePooled = True
End Function
Private Sub ObjectControl_Deactivate()
End Sub
Public Class clsLogon Inherits System.EnterpriseServices.ServicedComponent
Private Sub ObjectControl_Activate() Implements COMSVCSLib.ObjectControl.Activate
End Sub
Private Function ObjectControl_CanBePooled() As Boolean Implements COMSVCSLib.ObjectControl.CanBePooled
Return True
End Function
Private Sub ObjectControl_Deactivate() Implements COMSVCSLib.ObjectControl.Deactivate
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:
Implements ObjectControl
Private Sub ObjectControl_Activate()
End Sub
Private Function ObjectControl_CanBePooled() As Boolean
ObjectControl_CanBePooled = True
End Function
Private Sub ObjectControl_Deactivate()
End Sub
C# code:
public class clsLogon: COMSVCSLib.ObjectControl
{
public void Activate()
{
}
public bool CanBePooled()
{
return true;
}
public void Deactivate()
{
}
}
VB.NET code:
Public Class clsLogon Implements COMSVCSLib.ObjectControl
Private Sub ObjectControl_Activate() Implements COMSVCSLib.ObjectControl.Activate
End Sub
Private Function ObjectControl_CanBePooled() As Boolean Implements COMSVCSLib.ObjectControl.CanBePooled
Return True
End Function
Private Sub ObjectControl_Deactivate() Implements COMSVCSLib.ObjectControl.Deactivate
End Sub
6. CRAXDRT_CRVIEWERLibCtl
6.1. To CrystalReports
By using this option the converted application will not have any reference to the COM Component.
Map CRAXDRT and CRVIEWERLibCtl classes and enums to CrystalReports equivalents.
Private Sub Form_Load()
Dim objReport As CRAXDRT.Report
objReport = objApplication.OpenReport(App.Path & "Report.rpt", 1)
objReport.DiscardSavedData
End Sub
Private Sub Form_Load()
Dim tempReport As New CrystalDecisions.CrystalReports.Engine.ReportDocument()
tempReport.Load(My.Application.Info.DirectoryPath & "Report.rpt")
Dim objReport As CrystalDecisions.CrystalReports.Engine.ReportDocument = tempReport
objReport.Refresh()
End Sub
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:
Private Sub Form_Load()
Dim objReport As CRAXDRT.Report
objReport = objApplication.OpenReport(App.Path & "Report.rpt", 1)
objReport.DiscardSavedData
End Sub
Private Sub Form_Load()
Dim objReport As CRAXDRT.Report = objApplication.OpenReport(My.Application.Info.DirectoryPath & "Report.rpt", 1)
objReport.DiscardSavedData()
End Sub
7. CrystalReport
7.1. To CrystalReport.NET
Conversion of CrystalReport for Windows Forms using a helper class.
General Description:
CrystalReport is a business intelligence application, marketed to small and medium businesses. It allows the user to generate reports based on databases generated within Visual Basic.
Deployment Note:
The VBUC converts the CrystalReport OCX to a helper class.
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.
Private Sub Form_Load()
Dim newSidbEdit As CSTextLibCtl.sidbEdit
newSidbEdit.Text = "Hello"
newSidbEdit.Enabled = True
newSidbEdit.Visible = True
newSidbEdit.TabIndex = 4
End Sub
Private Sub Form_Load()
Dim newSidbEdit As MaskedTextBox
newSidbEdit.Text = "Hello"
newSidbEdit.Enabled = True
newSidbEdit.Visible = True
newSidbEdit.TabIndex = 4
End Sub
8.2. To ComponentOne C1Input controls
By using this option, the converted application will not have any reference to the COM Component.
This option maps:
CSTextLib classes to a Component One Winforms control equivalent.
CSTextLib enums to System.Windows.Forms enums.
Class
Maps to
CSTextLib.sicrEdit
C1.Win.C1Input.C1NumericEdit
CSTextLib.sicrEdit.BorderEffect
C1.Win.C1Input.C1NumericEdit.BorderStyle
CSTextLib.sidbEdit
C1.Win.C1Input.C1NumericEdit
CSTextLib.sidbEdit.SelLength
C1.Win.C1Input.C1NumericEdit.SelectionLength
CSTextLib.sidbEdit.SelStart
C1.Win.C1Input.C1NumericEdit.SelectionStart
CSTextLib.sidbEdit.Text
C1.Win.C1Input.C1NumericEdit.Text
CSTextLib.sidtEdit
C1.Win.C1Input.C1DateEdit
CSTextLib.sidtEdit.Justification
C1.Win.C1Input.C1DateEdit.TextAlign
CSTextLib.silgEdit
C1.Win.C1Input.C1NumericEdit
CSTextLib.silgEdit.Enabled
C1.Win.C1Input.C1NumericEdit.Enabled
CSTextLib.sitmEdit
C1.Win.C1Input.C1DateEdit
CSTextLib.sitmEdit.Value
C1.Win.C1Input.C1DateEdit.Value
CSTextLib.sitxEdit
C1.Win.C1Input.C1TextBox
CSTextLib.sitxEdit.Mask
C1.Win.C1Input.C1TextBox.EditMask
CSTextLib.enumBE
System.Windows.Forms.BorderStyle
CSTextLib.enumJU
System.Windows.Forms.HorizontalAlignment
Original VB6 code:
Private Sub Form_Load()
Dim newSidbEdit As CSTextLibCtl.sidbEdit
newSidbEdit.Text = "Hello"
newSidbEdit.Enabled = True
newSidbEdit.Visible = True
newSidbEdit.TabIndex = 4
End Sub
Private Sub Form_Load()
Dim newSidbEdit As C1.Win.C1Input.C1NumericEdit
newSidbEdit.Text = "Hello"
newSidbEdit.Enabled = True
newSidbEdit.Visible = True
newSidbEdit.TabIndex = 4
End Sub
8.3. 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()
Dim newSidbEdit As CSTextLibCtl.sidbEdit
newSidbEdit.Text = "Hello"
newSidbEdit.Enabled = True
newSidbEdit.Visible = True
newSidbEdit.TabIndex = 4
End Sub
Private Sub Form_Load()
Dim newSidbEdit As CSTextLib.sidbEdit
newSidbEdit.Text = "Hello"
newSidbEdit.Enabled = True
ReflectionHelper.LetMember(newSidbEdit, "Visible", True)
ReflectionHelper.LetMember(newSidbEdit, "TabIndex", 4)
End Sub
9. CTTips
9.1. To System.Windows.Forms.ToolTip
Convert TipsLib.ctTips classes to System.Windows.Forms.ToolTip.
By using this option, the converted application will not have any reference to the COM Component.
Class
Maps to
TipsLib.ctTips.Active
System.Windows.Forms.ToolTip.Active
TipsLib.ctTips.ShowText
System.Windows.Forms.ToolTip.Show
TipsLib.ctTips.HideTips
System.Windows.Forms.ToolTip.Hide
TipsLib.ctTips.Delay
System.Windows.Forms.ToolTip.Delay
TipsLib.ctTips.BackColor
System.Windows.Forms.ToolTip.BackColor
TipsLib.ctTips.ForeColor
System.Windows.Forms.ToolTip.ForeColor
TipsLib.ctTips.AddTips
System.Windows.Forms.ToolTip.SetToolTip
Original VB6 code:
Private Sub CommandExecute_Click()
...
ctTips1.Delay = 20
ctTips1.ShowText = "Operation done"
ctTips1.Active = True
End Sub
...
Private Sub Form_Load()
Me.ctTips1.AddTips Me.Option1.hWnd, "Adds operand 1 and operand 2 and displays the operation result"
Me.ctTips1.AddTips Me.Option2.hWnd, "Substracts operand 2 from operand 1 and displays the operation result"
Me.ctTips1.AddTips Me.Option3.hWnd, "Multiplies operand 1 and operand 2 and displays the operation result"
Me.ctTips1.AddTips Me.Option4.hWnd, "Divides operand 1 by operand 2 (float division) and displays the operation result"
Me.ctTips1.AddTips Me.Option5.hWnd, "Divides operand 1 by operand 2 (integer division) and displays the operation result"
Me.ctTips1.AddTips Me.Option6.hWnd, "Computes operand 1 module operand 2 and displays the operation result"
Me.ctTips1.AddTips Me.Option7.hWnd, "Computes operand 1 power operand 2 and displays the operation result"
End Sub
Private Sub TextOperand1_Click()
ctTips1.BackColor = vbWhite
End Sub
Private Sub TextOperand2_Click()
ctTips1.ForeColor = vbBlue
End Sub
C# code:
partial class Form1
{
...
public System.Windows.Forms.ToolTip ctTips1;
...
private void InitializeComponent()
{
...
this.ctTips1 = new System.Windows.Forms.ToolTip();
...
}
...
}
private void CommandExecute_Click(Object eventSender, EventArgs eventArgs)
{
...
ctTips1.InitialDelay = 20 * 100;
ctTips1.Show("Operation done", this.ActiveControl);
ctTips1.Active = true;
}
...
private void Form_Load()
{
this.ctTips1.SetToolTip(this.Option1, "Adds operand 1 and operand 2 and displays the operation result");
this.ctTips1.SetToolTip(this.Option2, "Substracts operand 2 from operand 1 and displays the operation result");
this.ctTips1.SetToolTip(this.Option3, "Multiplies operand 1 and operand 2 and displays the operation result");
this.ctTips1.SetToolTip(this.Option4, "Divides operand 1 by operand 2 (float division) and displays the operation result");
this.ctTips1.SetToolTip(this.Option5, "Divides operand 1 by operand 2 (integer division) and displays the operation result");
this.ctTips1.SetToolTip(this.Option6, "Computes operand 1 module operand 2 and displays the operation result");
this.ctTips1.SetToolTip(this.Option7, "Computes operand 1 power operand 2 and displays the operation result");
}
private void TextOperand1_Click(Object eventSender, EventArgs eventArgs)
{
ctTips1.BackColor = Color.White;
}
private void TextOperand2_Click(Object eventSender, EventArgs eventArgs)
{
ctTips1.ForeColor = Color.Blue;
}
VB.NET code:
Partial Class Form1
...
Public WithEvents ctTips1 As System.Windows.Forms.ToolTip
...
Private Sub InitializeComponent()
...
Me.ctTips1 = New System.Windows.Forms.ToolTip()
...
...
Private Sub CommandExecute_Click(ByVal eventSender As Object, ByVal eventArgs As EventArgs) Handles CommandExecute.Click
...
ctTips1.InitialDelay = 20 * 100
ctTips1.Show("Operation done", Me.ActiveControl)
ctTips1.Active = True
End Sub
...
Private Sub Form_Load()
Me.ctTips1.SetToolTip(Me.Option1, "Adds operand 1 and operand 2 and displays the operation result")
Me.ctTips1.SetToolTip(Me.Option2, "Substracts operand 2 from operand 1 and displays the operation result")
Me.ctTips1.SetToolTip(Me.Option3, "Multiplies operand 1 and operand 2 and displays the operation result")
Me.ctTips1.SetToolTip(Me.Option4, "Divides operand 1 by operand 2 (float division) and displays the operation result")
Me.ctTips1.SetToolTip(Me.Option5, "Divides operand 1 by operand 2 (integer division) and displays the operation result")
Me.ctTips1.SetToolTip(Me.Option6, "Computes operand 1 module operand 2 and displays the operation result")
Me.ctTips1.SetToolTip(Me.Option7, "Computes operand 1 power operand 2 and displays the operation result")
End Sub
Private Sub TextOperand1_Click(ByVal eventSender As Object, ByVal eventArgs As EventArgs) Handles TextOperand1.Click
ctTips1.BackColor = Color.White
End Sub
Private Sub TextOperand2_Click(ByVal eventSender As Object, ByVal eventArgs As EventArgs) Handles TextOperand2.Click
ctTips1.ForeColor = Color.Blue
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 CommandExecute_Click()
...
ctTips1.Delay = 20
ctTips1.ShowText = "Operation done"
ctTips1.Active = True
End Sub
...
Private Sub Form_Load()
Me.ctTips1.AddTips Me.Option1.hWnd, "Adds operand 1 and operand 2 and displays the operation result"
Me.ctTips1.AddTips Me.Option2.hWnd, "Substracts operand 2 from operand 1 and displays the operation result"
Me.ctTips1.AddTips Me.Option3.hWnd, "Multiplies operand 1 and operand 2 and displays the operation result"
Me.ctTips1.AddTips Me.Option4.hWnd, "Divides operand 1 by operand 2 (float division) and displays the operation result"
Me.ctTips1.AddTips Me.Option5.hWnd, "Divides operand 1 by operand 2 (integer division) and displays the operation result"
Me.ctTips1.AddTips Me.Option6.hWnd, "Computes operand 1 module operand 2 and displays the operation result"
Me.ctTips1.AddTips Me.Option7.hWnd, "Computes operand 1 power operand 2 and displays the operation result"
End Sub
Private Sub TextOperand1_Click()
ctTips1.BackColor = vbWhite
End Sub
Private Sub TextOperand2_Click()
ctTips1.ForeColor = vbBlue
End Sub
C# code:
partial class Form1
{
...
public AxTipsLib.AxctTips ctTips1;
...
private void InitializeComponent()
{
...
this.ctTips1 = new AxTipsLib.AxctTips();
...
}
...
}
private void CommandExecute_Click(Object eventSender, EventArgs eventArgs)
{
...
ctTips1.Delay = 20;
ctTips1.ShowText = "Operation done";
ctTips1.Active = true;
}
...
private void Form_Load()
{
this.ctTips1.AddTips(this.Option1.Handle.ToInt32(), "Adds operand 1 and operand 2 and displays the operation result");
this.ctTips1.AddTips(this.Option2.Handle.ToInt32(), "Substracts operand 2 from operand 1 and displays the operation result");
this.ctTips1.AddTips(this.Option3.Handle.ToInt32(), "Multiplies operand 1 and operand 2 and displays the operation result");
this.ctTips1.AddTips(this.Option4.Handle.ToInt32(), "Divides operand 1 by operand 2 (float division) and displays the operation result");
this.ctTips1.AddTips(this.Option5.Handle.ToInt32(), "Divides operand 1 by operand 2 (integer division) and displays the operation result");
this.ctTips1.AddTips(this.Option6.Handle.ToInt32(), "Computes operand 1 module operand 2 and displays the operation result");
this.ctTips1.AddTips(this.Option7.Handle.ToInt32(), "Computes operand 1 power operand 2 and displays the operation result");
}
private void TextOperand1_Click(Object eventSender, EventArgs eventArgs)
{
ctTips1.CtlBackColor = Color.White;
}
private void TextOperand2_Click(Object eventSender, EventArgs eventArgs)
{
ctTips1.CtlForeColor = Color.Blue;
}
VB.NET code:
Partial Class Form1
...
Public WithEvents ctTips1 As AxTipsLib.AxctTips
...
Private Sub InitializeComponent()
...
Me.ctTips1 = New AxTipsLib.AxctTips()
...
...
Private Sub CommandExecute_Click(ByVal eventSender As Object, ByVal eventArgs As EventArgs) Handles CommandExecute.Click
...
ctTips1.Delay = 20
ctTips1.ShowText = "Operation done"
ctTips1.Active = True
End Sub
...
Private Sub Form_Load()
Me.ctTips1.AddTips(Me.Option1.Handle.ToInt32(), "Adds operand 1 and operand 2 and displays the operation result")
Me.ctTips1.AddTips(Me.Option2.Handle.ToInt32(), "Substracts operand 2 from operand 1 and displays the operation result")
Me.ctTips1.AddTips(Me.Option3.Handle.ToInt32(), "Multiplies operand 1 and operand 2 and displays the operation result")
Me.ctTips1.AddTips(Me.Option4.Handle.ToInt32(), "Divides operand 1 by operand 2 (float division) and displays the operation result")
Me.ctTips1.AddTips(Me.Option5.Handle.ToInt32(), "Divides operand 1 by operand 2 (integer division) and displays the operation result")
Me.ctTips1.AddTips(Me.Option6.Handle.ToInt32(), "Computes operand 1 module operand 2 and displays the operation result")
Me.ctTips1.AddTips(Me.Option7.Handle.ToInt32(), "Computes operand 1 power operand 2 and displays the operation result")
End Sub
Private Sub TextOperand1_Click(ByVal eventSender As Object, ByVal eventArgs As EventArgs) Handles TextOperand1.Click
ctTips1.CtlBackColor = Color.White
End Sub
Private Sub TextOperand2_Click(ByVal eventSender As Object, ByVal eventArgs As EventArgs) Handles TextOperand2.Click
ctTips1.CtlForeColor = Color.Blue
End Sub
10. CWUIControlsLib
10.1. To NationalInstruments Library
General Description: This feature maps the "CWUIControlsLib" set of classes to their .NET equivalent in the "NationalInstruments" library. Both the VB6 and the .NET libraries are owned by the same company called National Instruments, so there is no better alternative when mapping the set of controls defined in the VB6 library to .NET. More information about the company can be found here: https://www.ni.com/en-us.html
This feature maps the "CWUIControlsLib" set of classes to their .NET equivalent in the "NationalInstruments" library.
...
edit1.FormatMode = NationalInstruments.UI.NumericFormatMode.CreateGenericMode("0.")
edit1.Value = 40
edit1.Range = New NationalInstruments.UI.Range(1, edit1.Range.Maximum)
edit1.CoercionIntervalBase = 0
edit1.CoercionInterval = 1
edit1.CoercionMode = NationalInstruments.UI.NumericCoercionMode.ToInterval
edit1.CoercionInterval = edit1.CoercionIntervalBase
edit1.Range = New NationalInstruments.UI.Range(edit1.Range.Minimum, edit1.Range.Maximum)
edit1.BorderStyle = BorderStyle.FixedSingle
edit1.TextAlign = HorizontalAlignment.Left
edit1.UpDownAlign = LeftRightAlignment.Left
edit1.ForeColor = SystemColors.WindowText
edit1.InteractionMode = NationalInstruments.UI.NumericEditInteractionModes.Buttons Or NationalInstruments.UI.NumericEditInteractionModes.Text Or NationalInstruments.UI.NumericEditInteractionModes.ArrowKeys
If edit1.CoercionMode <> NationalInstruments.UI.NumericCoercionMode.None Then
edit1.CoercionInterval = 88
End If
...
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.
By using this option the converted application will not have any reference to the COM Component
This option maps:
The fpBtn class to the Windows Button control.
fpBtnAtlLibCtl constants to the DockStyle enum.
Class
Maps to
fpBtnAtlLib.fpBtn
System.Windows.Forms.Button
fpBtnAtlLib.fpBtn.Enabled
System.Windows.Forms.Button.Enabled
fpBtnAtlLib.fpBtn.Text
System.Windows.Forms.Button.Text
fpBtnAtlLib.fpBtn.Visible
System.Windows.Forms.Button.Visible
fpBtnAtlLib.fpBtn.BackColor
System.Windows.Forms.Button.BackColor
fpBtnAtlLib.fpBtn.TabIndex
System.Windows.Forms.Button.TabIndex
fpBtnAtlLib.fpBtn.TabStop
System.Windows.Forms.Button.TabStop
fpBtnAtlLib.AutoSizeConstants
System.Windows.Forms.DockStyle
fpBtnAtlLib.AutoSizeConstants.fpAutoSizeNone
System.Windows.Forms.DockStyle.fpAutoSizeNone
Original VB6 code:
Private Sub Form_Load()
fpBtn1.Enabled = True
fpBtn1.Text = "Click button"
fpBtn1.BackColor = &H8000000D
End Sub
Private Sub fpBtn1_Click()
MsgBox "fp Button Clicked"
End Sub
Private Sub Form_Load()
fpBtn1.Enabled = True
fpBtn1.Text = "Click button"
fpBtn1.BackColor = SystemColors.Highlight
End Sub
Private Sub fpBtn1_Click(ByVal eventSender As Object, ByVal eventArgs As EventArgs) Handles fpBtn1.Click
MessageBox.Show("fp Button Clicked", My.Application.Info.Title)
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:
Private Sub Form_Load()
fpBtn1.Enabled = True
fpBtn1.Text = "Click button"
fpBtn1.BackColor = &H8000000D
End Sub
Private Sub fpBtn1_Click()
MsgBox "fp Button Clicked"
End Sub
Private Sub Form_Load()
fpBtn1.Enabled = True
fpBtn1.Text = "Click button"
fpBtn1.BackColor = SystemColors.Highlight
End Sub
Private Sub fpBtn1_ClickEvent(ByVal eventSender As Object, ByVal eventArgs As EventArgs) Handles fpBtn1.ClickEvent
MessageBox.Show("fp Button Clicked", My.Application.Info.Title)
End Sub
12. ListPro
12.1. To native and helper classes
ListPro allows you to display list items, display single records, or items on multiple rows. FarPoint's List Pro fpCombo control will be mapped to a helper class based on the .NET ComboBox called UpgradeHelpers.Gui.ComboBoxHelper. The List Pro fpList control will be mapped to a native System.Windows.Forms.ListBox.
The VBUC is supporting the ListPro 2.0 and ListPro 3.0 versions of the control.
private void Form_Load()
{
fpCombo1.AddItem("Hello");
fpCombo1.AddItem("Hello Again", 2);
//UPGRADE_ISSUE: (2064) LpLib.fpCombo property fpCombo1.BorderColor was not upgraded.
Color X1 = fpCombo1.getBorderColor();
int X2 = fpCombo1.ListCount;
int X3 = fpCombo1.Row;
fpCombo1.RemoveItem(0);
fpCombo1.Clear();
fpCombo1.Text = "Hi there";
//UPGRADE_WARNING: (2081) AddItem has a new behavior. More Information: https://docs.mobilize.net/vbuc/ewis#2081
fpList1.Items.Add("Hello");
//UPGRADE_WARNING: (2081) AddItem has a new behavior. More Information: https://docs.mobilize.net/vbuc/ewis#2081
fpList1.Items.Add("Hello Again");
//UPGRADE_ISSUE: (2064) LpLib.fpList property fpList1.BorderColor was not upgraded. More Information: https://docs.mobilize.net/vbuc/ewis#2064
X1 = fpList1.getBorderColor();
X2 = fpList1.Items.Count;
//UPGRADE_ISSUE: (2064) LpLib.fpList property fpList1.Row was not upgraded. More Information: https://docs.mobilize.net/vbuc/ewis#2064
X3 = fpList1.getRow();
//UPGRADE_ISSUE: (2064) LpLib.fpList method fpList1.RemoveItem was not upgraded. More Information: https://docs.mobilize.net/vbuc/ewis#2064
fpList1.RemoveItem(0);
fpList1.Items.Clear();
fpList1.Text = "Hi there";
}
VB.NET code:
Private Sub Form_Load()
fpCombo1.AddItem("Hello")
fpCombo1.AddItem("Hello Again", 2)
'UPGRADE_ISSUE: (2064) LpLib.fpCombo property fpCombo1.BorderColor was not upgraded.'
Dim X1 As Color = fpCombo1.getBorderColor()
Dim X2 As Integer = fpCombo1.ListCount
Dim X3 As Integer = fpCombo1.Row
fpCombo1.RemoveItem(0)
fpCombo1.Clear()
fpCombo1.Text = "Hi there"
'UPGRADE_WARNING: (2081) AddItem has a new behavior. More Information: https://docs.mobilize.net/vbuc/ewis#2081
fpList1.Items.Add("Hello")
'UPGRADE_WARNING: (2081) AddItem has a new behavior. More Information: https://docs.mobilize.net/vbuc/ewis#2081
fpList1.Items.Add("Hello Again")
'UPGRADE_ISSUE: (2064) LpLib.fpList property fpList1.BorderColor was not upgraded. More Information: https://docs.mobilize.net/vbuc/ewis#2064
X1 = fpList1.getBorderColor()
X2 = fpList1.Items.Count
'UPGRADE_ISSUE: (2064) LpLib.fpList property fpList1.Row was not upgraded. More Information: https://docs.mobilize.net/vbuc/ewis#2064
X3 = fpList1.getRow()
'UPGRADE_ISSUE: (2064) LpLib.fpList method fpList1.RemoveItem was not upgraded. More Information: https://docs.mobilize.net/vbuc/ewis#2064
fpList1.RemoveItem(0)
fpList1.Items.Clear()
fpList1.Text = "Hi there"
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 Form_Load()
fpCombo1.AddItem "Hello"
fpCombo1.AddItem "Hello Again", 2
X1 = fpCombo1.BorderColor
X2 = fpCombo1.ListCount
X3 = fpCombo1.Row
fpCombo1.RemoveItem 0
fpCombo1.Clear
fpCombo1.Text = "Hi there"
End Sub
C# code:
private void Form_Load()
{
fpCombo1.AddItem("Hello");
fpCombo1.AddItem("Hello Again", 2);
Color X1 = fpCombo1.BorderColor;
int X2 = fpCombo1.ListCount;
int X3 = fpCombo1.Row;
fpCombo1.RemoveItem(0);
fpCombo1.Clear();
fpCombo1.CtlText = "Hi there";
}
VB.NET code:
Private Sub Form_Load()
fpCombo1.AddItem("Hello")
fpCombo1.AddItem("Hello Again", 2)
Dim X1 As Color = fpCombo1.BorderColor
Dim X2 As Integer = fpCombo1.ListCount
Dim X3 As Integer = fpCombo1.Row
fpCombo1.RemoveItem(0)
fpCombo1.Clear()
fpCombo1.CtlText = "Hi there"
End Sub
13. MemoLibfpMemo
13.1. To System.Windows.Forms.TextBox
Convert MemoLib.fpMemo classes to System.Windows.Forms.TextBox.
By using this option the converted application will not have any reference to the COM Component.
Class
Maps to
MemoLib.fpMemo.BackColor
System.Windows.Forms.TextBox.BackColor
MemoLib.fpMemo.Enabled
System.Windows.Forms.TextBox.Enabled
MemoLib.fpMemo.ForeColor
System.Windows.Forms.TextBox.ForeColor
MemoLib.fpMemo.HideSelection
System.Windows.Forms.TextBox.HideSelection
MemoLib.fpMemo.ScrollBars
System.Windows.Forms.TextBox.ScrollBars
MemoLib.fpMemo.TabIndex
System.Windows.Forms.TextBox.TabIndex
MemoLib.fpMemo.Text
System.Windows.Forms.TextBox.Text
MemoLib.fpMemo.WordWrap
System.Windows.Forms.TextBox.WordWrap
Original VB6 code:
Private Sub Form_Load()
...
X1 = fpMemo1.BackColor
X2 = fpMemo1.ForeColor
fpMemo1.Enabled = False
fpMemo1.Text = "Hello"
fpMemo1.Visible = False
fpMemo1.ScrollBars = BothAuto
End Sub
Private Sub Form_Load()
Dim X1 As Color = fpMemo1.BackColor
Dim X2 As Color = fpMemo1.ForeColor
fpMemo1.Enabled = False
fpMemo1.Text = "Hello"
fpMemo1.Visible = False
fpMemo1.ScrollBars = ScrollBars.Both
End Sub
13.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()
fpCombo1.AddItem "Hello"
fpCombo1.AddItem "Hello Again", 2
X1 = fpCombo1.BorderColor
X2 = fpCombo1.ListCount
X3 = fpCombo1.Row
fpCombo1.RemoveItem 0
fpCombo1.Clear
fpCombo1.Text = "Hi there"
End Sub
Private Sub Form_Load()
Dim X1 As Color = fpMemo1.CtlBackColor
Dim X2 As Color = fpMemo1.CtlForeColor
fpMemo1.Enabled = False
fpMemo1.Text = "Hello"
fpMemo1.Visible = False
fpMemo1.ScrollBars = MemoLib.ScrollBarsConstants.BothAuto
End Sub
14. PictureBox
14.1. To System.Windows.Forms.PictureBox
Converts VB.PictureBox to a .NET native PictureBox control.
This option converts the PictureBox control to .NET PictureBox control from Windows.Forms.
This optional feature maps PictureBox control to its .NET counterpart. It's a control used to display images in Windows Forms.
'Load Image'
Private Sub Command1_Click()
Picture2.Picture = LoadPicture(App.Path & "\Square.bmp")
End Sub
'Clear Image'
Private Sub Command2_Click()
Picture2.Picture = Nothing
End Sub
'Paint in PictureBox'
Private Sub Picture2_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Static oldX As Single
Static oldY As Single
Picture2.Line (oldX, oldY)-(X, Y), vbBlue
oldX = X
oldY = Y
End Sub
'Load Image'
Private Sub Command1_Click(ByVal eventSender As Object, ByVal eventArgs As EventArgs) Handles Command1.Click
Picture2.Image = Image.FromFile(My.Application.Info.DirectoryPath & "\Square.bmp")
End Sub
'Clear Image'
Private Sub Command2_Click(ByVal eventSender As Object, ByVal eventArgs As EventArgs) Handles Command2.Click
Picture2.Image = Nothing
End Sub
'Paint in PictureBox'
Private Sub Picture2_MouseMove(ByVal eventSender As Object, ByVal eventArgs As MouseEventArgs) Handles Picture2.MouseMove
Dim Button As Integer = IIf(eventArgs.Button = MouseButtons.Left, 1, IIf(eventArgs.Button = MouseButtons.Right, 2, 4))
Dim Shift As Integer = Control.ModifierKeys / 65536
Dim X As Single = eventArgs.X * 15
Dim Y As Single = eventArgs.Y * 15
Static oldX, oldY As Single
Using g As Graphics = Picture2.CreateGraphics()
g.DrawLine(New Pen(Color.Blue), oldX, oldY, X, Y)
End Using
oldX = X
oldY = Y
End Sub
14.2. To System.Windows.Forms.Picture helper class
Converts VB.PictureBox to a PictureBoxExtended helper class.
This option converts the PictureBox control by using a helper class, but with a high automation level.
This optional feature maps PictureBox control through a set of helper objects to provide equivalent behavior.
Class
Maps to
Vb.PictureBox
UpgradeHelpers.Gui.PictureBoxExtended
Vb.PictureBox.Picture
UpgradeHelpers.Gui.PictureBoxExtended.Image
Vb.PictureBox.CurrentX
UpgradeHelpers.Gui.PictureBoxExtended.CurrentX
Vb.PictureBox.CurrentY
UpgradeHelpers.Gui.PictureBoxExtended.CurrentY
Vb.PictureBox.ScaleHeight
UpgradeHelpers.Gui.PictureBoxExtended.ScaleHeight
Vb.PictureBox.ScaleLeft
UpgradeHelpers.Gui.PictureBoxExtended.ScaleLeft
Vb.PictureBox.FillStyle
UpgradeHelpers.Gui.PictureBoxExtended.FillStyle
Vb.PictureBox.FillColor
UpgradeHelpers.Gui.PictureBoxExtended.FillColor
Vb.PictureBox.Print
UpgradeHelpers.Gui.PictureBoxExtended.Print
Vb.PictureBox.Circle
UpgradeHelpers.Gui.PictureBoxExtended.Circle
Vb.PictureBox.Cls
UpgradeHelpers.Gui.PictureBoxExtended.Cls
VBRUN.DrawStyleConstants
System.Drawing.Drawing2D.DashStyle
VBRUN.FillStyleConstants.vbFsSolid
UpgradeHelpers.Gui.FillStyleConstants.vbFsSolid
VBRUN.FillStyleConstants.vbCross
UpgradeHelpers.Gui.FillStyleConstants.vbCross
Original VB6 code:
'Load Image'
Private Sub Command1_Click()
Picture2.Picture = LoadPicture(App.Path & "\Square.bmp")
End Sub
'Clear Image'
Private Sub Command2_Click()
Picture2.Picture = Nothing
End Sub
'Paint in PictureBox'
Private Sub Picture2_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Static oldX As Single
Static oldY As Single
Picture2.Line (oldX, oldY)-(X, Y), vbBlue
oldX = X
oldY = Y
End Sub
'Load Image'
Private Sub Command1_Click(ByVal eventSender As Object, ByVal eventArgs As EventArgs) Handles Command1.Click
Picture2.Image = Image.FromFile(My.Application.Info.DirectoryPath & "\Square.bmp")
End Sub
'Clear Image'
Private Sub Command2_Click(ByVal eventSender As Object, ByVal eventArgs As EventArgs) Handles Command2.Click
Picture2.Image = Nothing
End Sub
'Paint in PictureBox'
Private Sub Picture2_MouseMove(ByVal eventSender As Object, ByVal eventArgs As MouseEventArgs) Handles Picture2.MouseMove
Dim Button As Integer = IIf(eventArgs.Button = MouseButtons.Left, 1, IIf(eventArgs.Button = MouseButtons.Right, 2, 4))
Dim Shift As Integer = Control.ModifierKeys / 65536
Dim X As Single = eventArgs.X * 15
Dim Y As Single = eventArgs.Y * 15
Static oldX, oldY As Single
Picture2.Line(oldX, oldY, X, Y, Color.Blue)
oldX = X
oldY = Y
End Sub
15. Printer
15.1. To .NET Printer helper class
Converts VB.Global.Printer to a .NET native Printer helper class.
This option converts the class Printer by using a .NET native Printer helper class.
This optional feature maps Printer to its .NET counterpart by using a helper.
Every mapping of VB.Global.Printer will be upgraded to PrinterHelper.Printer.
Original VB6 code:
Private Sub Command1_Click()
Printer.FontName = "Verdana"
Printer.FontSize = 16
Printer.FontBold = True
Printer.FontItalic = True
Printer.FontUnderline = True
Printer.Print "This is an example"
Printer.EndDoc
End Sub
Private Sub Form_Load()
Dim prnPrinter As Printer
For Each prnPrinter In Printers
If prnPrinter.DeviceName = "Device1" Then
Set Printer = prnPrinter
Exit For
End If
Next
End Sub
C# code:
private void Command1_Click(Object eventSender, EventArgs eventArgs)
{
PrinterHelper.Printer.FontName = "Arial";
PrinterHelper.Printer.FontSize = 14;
PrinterHelper.Printer.FontBold = true;
PrinterHelper.Printer.FontItalic = true;
PrinterHelper.Printer.FontUnderline = true;
PrinterHelper.Printer.Print("This is an example");
PrinterHelper.Printer.EndDoc();
}
//UPGRADE_WARNING: (2080) Form_Load event was upgraded to Form_Load method and has a new behavior.
private void Form_Load()
{
PrinterHelper prnPrinter = null;
foreach (PrinterHelper prnPrinterIterator in PrinterHelper.Printers)
{
prnPrinter = prnPrinterIterator;
if (PrinterHelper.Printer.DeviceName == "Device1")
{
PrinterHelper.Printer = prnPrinter;
break;
}
}
}
VB.NET code:
Private Sub Command1_Click(ByVal eventSender As Object, ByVal eventArgs As EventArgs) Handles Command1.Click
PrinterHelper.Printer.FontName = "Arial"
PrinterHelper.Printer.FontSize = 14
PrinterHelper.Printer.FontBold = True
PrinterHelper.Printer.FontItalic = True
PrinterHelper.Printer.FontUnderline = True
PrinterHelper.Printer.Print("This is an example")
PrinterHelper.Printer.EndDoc()
End Sub
'UPGRADE_WARNING: (2080) Form_Load event was upgraded to Form_Load method and has a new behavior.'
Private Sub Form_Load()
Dim prnPrinter As PrinterHelper
For Each prnPrinterIterator As PrinterHelper In PrinterHelper.Printers
prnPrinter = prnPrinterIterator
If PrinterHelper.Printer.DeviceName = "Device1" Then
PrinterHelper.Printer = prnPrinter
Exit For
End If
Next prnPrinterIterator
End Sub
15.2. To PowerPacks helper class
Convert VB.Global.Printer to Helper using VisualBasic.PowerPacks.Printing.Compatibility.VB6.Printer.
This option converts the class Printer through helper using Printer from namespace Microsoft.VisualBasic.
This optional feature maps Printer to its .NET counterpart through a helper using Printer from Microsoft.VisualBasic.PowerPacks.Printing.Compatibility.VB6 provided by Microsoft.
The PowerPacks provides a Printer object for use by upgraded VB6 code.
Class
Maps to
Vb.Printer.FontName
PowerPacksPrinterHelper.Instance.FontName
Vb.Printer.ColorMode
PowerPacksPrinterHelper.Instance.ColorMode
Vb.Printer.Copies
PowerPacksPrinterHelper.Instance.Copies
Vb.Printer.CurrentX
PowerPacksPrinterHelper.Instance.CurrentX
Vb.Printer.CurrentY
PowerPacksPrinterHelper.Instance.CurrentY
Vb.Printer.DeviceName
PowerPacksPrinterHelper.Instance.DeviceName
Vb.Printer.FontItalic
PowerPacksPrinterHelper.Instance.FontItalic
Vb.Printer.FontSize
PowerPacksPrinterHelper.Instance.FontSize
Original VB6 code:
Private Sub Command1_Click()
Printer.FontName = "Verdana"
Printer.FontSize = 16
Printer.FontBold = True
Printer.FontItalic = True
Printer.FontUnderline = True
Printer.Print "This is an example"
Printer.EndDoc
End Sub
Private Sub Form_Load()
Dim prnPrinter As Printer
For Each prnPrinter In Printers
If prnPrinter.DeviceName = "Device1" Then
Set Printer = prnPrinter
Exit For
End If
Next
End Sub
C# code:
private void Command1_Click(Object eventSender, EventArgs eventArgs)
{
PowerPacksPrinterHelper.Instance.FontName = "Arial";
PowerPacksPrinterHelper.Instance.FontSize = 14;
PowerPacksPrinterHelper.Instance.FontBold = true;
PowerPacksPrinterHelper.Instance.FontItalic = true;
PowerPacksPrinterHelper.Instance.FontUnderline = true;
PowerPacksPrinterHelper.Instance.Print("This is an example");
PowerPacksPrinterHelper.Instance.EndDoc();
}
//UPGRADE_WARNING: (2080) Form_Load event was upgraded to Form_Load method and has a new behavior.
private void Form_Load()
{
PrinterHelper prnPrinter = null;
foreach (PrinterHelper prnPrinterIterator in PrinterHelper.Printers)
{
prnPrinter = prnPrinterIterator;
if (PowerPacksPrinterHelper.Instance.DeviceName == "Device1")
{
PrinterHelper.Printer = prnPrinter;
break;
}
}
}
VB.NET code:
Private Sub Command1_Click(ByVal eventSender As Object, ByVal eventArgs As EventArgs) Handles Command1.Click
PowerPacksPrinterHelper.Instance.FontName = "Arial"
PowerPacksPrinterHelper.Instance.FontSize = 14
PowerPacksPrinterHelper.Instance.FontBold = True
PowerPacksPrinterHelper.Instance.FontItalic = True
PowerPacksPrinterHelper.Instance.FontUnderline = True
PowerPacksPrinterHelper.Instance.Print("This is an example")
PowerPacksPrinterHelper.Instance.EndDoc()
End Sub
'UPGRADE_WARNING: (2080) Form_Load event was upgraded to Form_Load method and has a new behavior.'
Private Sub Form_Load()
Dim prnPrinter As PrinterHelper
For Each prnPrinterIterator As PrinterHelper In PrinterHelper.Printers
prnPrinter = prnPrinterIterator
If PowerPacksPrinterHelper.Instance.DeviceName = "Device1" Then
PrinterHelper.Printer = prnPrinter
Exit For
End If
Next prnPrinterIterator
End Sub
16. TDBDate6
16.1. To System.Windows.Forms.DateTimePicker
Convert TDBDate6.TDBDate classes to System.Windows.Forms.DateTimePicker.
By using this option the converted application will not have any reference to the COM Component.
Class
Maps to
TDBDate6.TDBDate.Enabled
System.Windows.Forms.DateTimePicker.Enabled
TDBDate6.TDBDate.Font
System.Windows.Forms.DateTimePicker.Font
TDBDate6.TDBDate.Height
System.Windows.Forms.DateTimePicker.Height
TDBDate6.TDBDate.Left
System.Windows.Forms.DateTimePicker.Left
TDBDate6.TDBDate.Text
System.Windows.Forms.DateTimePicker.Text
TDBDate6.TDBDate.ValueIsNull
System.Windows.Forms.DateTimePicker.ValueIsNull
TDBDate6.TDBDate.Width
System.Windows.Forms.DateTimePicker.Width
TDBDate6.TDBDate.MaxDate
System.Windows.Forms.DateTimePicker.MaxDate
Original VB6 code:
Private Sub Form_Load()
Dim X1 As TDBDate
X1.Enabled = True
Font1 = X1.Font
X1.Height = 450
X1.Left = 150
Value1 = X1.Value
X1.MaxDate = "12/31/2025"
Tex1 = X1.Text
X1.Text = "New Date"
End Sub
Private Sub Form_Load()
Dim X1 As DateTimePicker
X1.Enabled = True
Dim Font1 As String = X1.Font.Name
X1.Height = 450
X1.Left = 150
Dim Value1 As Object = X1.GetValue()
X1.MaxDate = CDate("12/31/2025")
Dim Tex1 As String = X1.Text
X1.Text = "New Date"
End Sub
16.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()
Dim X1 As TDBDate
X1.Enabled = True
Font1 = X1.Font
X1.Height = 450
X1.Left = 150
Value1 = X1.Value
X1.MaxDate = "12/31/2025"
Tex1 = X1.Text
X1.Text = "New Date"
End Sub
Private Sub Form_Load()
Dim X1 As AxTDBDate6.AxTDBDate
X1.Enabled = True
Dim Font1 As String = X1.Font.Name
X1.Height = 30
X1.Left = 10
Dim Value1 As Object = X1.Value
X1.MaxDate = "12/31/2025"
Dim Tex1 As String = X1.CtlText
X1.CtlText = "New Date"
End Sub
17. TDBTime6
17.1. To System.Windows.Forms.DateTimePicker
Convert TDBTime6.TDBTime classes to System.Windows.Forms.DateTimePicker.
By using this option the converted application will not have any reference to the COM Component.
Class
Maps to
TDBTime6.TDBTime.Enabled
System.Windows.Forms.DateTimePicker.Enabled
TDBTime6.TDBTime.Top
System.Windows.Forms.DateTimePicker.Top
TDBTime6.TDBTime.Height
System.Windows.Forms.DateTimePicker.Height
TDBTime6.TDBTime.Left
System.Windows.Forms.DateTimePicker.Left
TDBTime6.TDBTime.Text
System.Windows.Forms.DateTimePicker.Text
TDBTime6.TDBTime.ValueIsNull
System.Windows.Forms.DateTimePicker.ValueIsNull
TDBTime6.TDBTime.Width
System.Windows.Forms.DateTimePicker.Width
TDBTime6.TDBTime.TabIndex
System.Windows.Forms.DateTimePicker.TabIndex
Original VB6 code:
Private Sub Form_Load()
Dim x1 As TDBTime
x1.Enabled = True
Font1 = x1.Font
x1.Height = 600
x1.Text = "New Time"
x1.Top = 150
x1.Value = "11:32:20"
Value1 = x1.Value
End Sub
C# code:
private void Form_Load()
{
DateTimePicker x1 = null;
x1.Enabled = true;
string Font1 = x1.Font.Name;
x1.Height = 600;
x1.Text = "New Time";
x1.Top = 150;
//UPGRADE_WARNING: (2081) Value has a new behavior.
x1.SetValue("11:32:20");
object Value1 = x1.GetValue();
}
VB.NET code:
Private Sub Form_Load()
Dim x1 As DateTimePicker
x1.Enabled = True
Dim Font1 As String = x1.Font.Name
x1.Height = 600
x1.Text = "New Time"
x1.Top = 150
'UPGRADE_WARNING: (2081) Value has a new behavior.'
x1.SetValue("11:32:20")
Dim Value1 As Object = x1.GetValue()
End Sub
17.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()
Dim x1 As TDBTime
x1.Enabled = True
Font1 = x1.Font
x1.Height = 600
x1.Text = "New Time"
x1.Top = 150
x1.Value = "11:32:20"
Value1 = x1.Value
End Sub
Private Sub Form_Load()
Dim x1 As AxTDBTime6.AxTDBTime
x1.Enabled = True
Dim Font1 As String = x1.Font.Name
x1.Height = 40
x1.CtlText = "New Time"
x1.Top = 10
x1.Value = "11:32:20"
Dim Value1 As Object = x1.Value
End Sub
18. TeeChart
18.1. To Steema TeeChart for .NET v4
Convert Steema TeeChart to .NET Steema TeeChart.
This option converts the TeeChart control to the .NET TeeChart control.
General Description:
This optional feature maps Steema TeeChart Pro Activex Control v5 to its .NET counterpart provided by the same company: Steema TeeChart for .NET v4.
Class
Maps to
TeeChart.TChart
Steema.TeeChart.TChart
TeeChart.ILegend
Steema.TeeChart.Legend
TeeChart.IExport
Steema.TeeChart.Export.Exports
TeeChart.ISeries
Steema.TeeChart.Styles.Series
TeeChart.IValueList
Steema.TeeChart.Styles.ValueList
TeeChart.EVerticalAxis
Steema.TeeChart.Styles.VerticalAxis
TeeChart.IGanttSeries
Steema.TeeChart.Styles.Gantt
TeeChart.IPointer
Steema.TeeChart.Styles.SeriesPointer
TeeChart.EPointerStyle
Steema.TeeChart.Styles.PointerStyles
TeeChart.ITitles
Steema.TeeChart.Header
TeeChart.IPanel
Steema.TeeChart.Panel
TeeChart.ESeriesClass
Steema.TeeChart.Styles.*, the migration depends on the context:
Steema.TeeChart.Styles.Bar
Steema.TeeChart.Styles.Gantt
Steema.TeeChart.Styles.Line
Steema.TeeChart.Styles.Points
TeeChart.ICanvas
Steema.TeeChart.Drawing.Graphics3D
TeeChart.IPen
The migration depends on the context, the following classes are used:
Steema.TeeChart.Drawing.ChartPen
Steema.TeeChart.Axis.GridPen
Steema.TeeChart.Axis.TicksPen
TeeChart.EChartPenStyle
System.Drawing.Drawing2D.DashStyle
TeeChart.IBrush
Steema.TeeChart.Drawing.ChartBrush
TeeChart.IAxes
Steema.TeeChart.Axes
TeeChart.IAxis
Steema.TeeChart.Axis
TeeChart.IAxisTitle
Steema.TeeChart.AxisTitle
TeeChart.IAxisLabels
Steema.TeeChart.AxisLabels
TeeChart.EAxisLabelStyle
Steema.TeeChart.AxisLabelStyle
TeeChart.IChartFont
Steema.TeeChart.Drawing.ChartFont
Original VB6 code:
Dim ctl As TChart
Set ctl = TChart1
ctl.Series(0).Clear
For i = 1 To 10
ctl.Series(0).Add 500 * Rnd + 100, "P" & i, 65535 / i
Next i
C# code:
Steema.TeeChart.TChart ctl = TChart1;
ctl.Series[0].Clear();
for (int i = 1; i <= 10; i++)
{
ctl.Series[0].Add(500 * VBMath.Rnd() + 100, "P" + Convert.ToString(i), 65535 / Convert.ToDouble(i);
}
VB.NET code:
Dim ctl As Steema.TeeChart.TChart = TChart1
ctl.Series(0).Clear()
For i As Integer = 1 To 10
ctl.Series(0).Add(500 * VBMath.Rnd() + 100, CDbl("P" & i), CStr(65535 / i))
Next i
18.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:
Dim ctl As TChart
Set ctl = TChart1
ctl.Series(0).Clear
For i = 1 To 10
ctl.Series(0).Add 500 * Rnd + 100, "P" & i, 65535 / i
Next i
C# code:
AxTeeChart.AxTChart ctl = TChart1;
ctl.Series(0).Clear();
for (int i = 1; i <= 10; i++)
{
ctl.Series(0).Add(500 * VBMath.Rnd() + 100, "P" + i.ToString(), ColorTranslator.FromOle(65535 / ((int) i)));
}
VB.NET code:
Dim ctl As AxTeeChart.AxTChart = TChart1
ctl.Series(0).Clear()
For i As Integer = 1 To 10
ctl.Series(0).Add(500 * VBMath.Rnd() + 100, "P" & i, ColorTranslator.FromOle(65535 / i))
Next i
19. VsPrinter
19.1. To ComponentOne C1PrintPreviewControl helper class
Conversion of ComponentOne VSPrinter using a C1Report helper class.
General Description:
The VSPrinter control makes it easy to create documents and reports for printing and print previewing from your applications. It only takes one statement to print plain text or RTF files, and a little more work to print graphics, tables, and formatted text. You have complete control over the printing device and document layout, including paper size and orientation, number of columns, headers and footers, page borders, shading, fonts, and so on.
Deployment Note:
The VBUC converts the Component One VSPrinter to a C1Report helper class.
Private Sub RenderFile()
' Set up the document'
vp.DocName = "VSPrinter Sample"
vp.Header = "Sample||Page %d"
vp.Footer = Format(Now, "dd-mmm-yy") & "||" & FileName
vp.PageBorder = pbAll
'Read file'
Dim sText As String
Open FileName For Binary As #1
sText = Input$(LOF(1), 1)
Close #1
'Start document'
vp.StartDoc
vp.Paragraph = sText
vp.Text = vbNewLine & "This is a test of vsPrinter Text property!"
'appends to exisitng text.'
vp.EndDoc
End Sub
C# code:
private void RenderFile()
{
// Set up the document
vp.DocName = "VSPrinter Sample";
vp.Header = "Sample||Page %d";
vp.Footer = DateTime.Now.ToString("dd-MMM-yy") + "||" + FileName;
vp.PageBorder = UpgradeHelpers.C1Report.C1PrintDocumentExtension.PageBorderSettings.pbAll;
//Read file
string sText = "";
FileSystem.FileOpen(1, FileName, OpenMode.Binary, OpenAccess.Default, OpenShare.Default, -1);
sText = FileSystem.InputString(1, (int) FileSystem.LOF(1));
FileSystem.FileClose(1);
//Start document
vp.StartDoc();
vp.Paragraph = sText;
vp.Text = Environment.NewLine + "This is a test of vsPrinter Text property!";
//appends to exisitng text.
vp.EndDoc();
}
VB.NET code:
Private Sub RenderFile()
' Set up the document'
vp.DocName = "VSPrinter Sample"
vp.Header = "Sample||Page %d"
vp.Footer = DateTime.Now.ToString("dd-MMM-yy") & "||" & FileName
vp.PageBorder = UpgradeHelpers.C1Report.C1PrintDocumentExtension.PageBorderSettings.pbAll
'Read file'
Dim sText As String = ""
FileSystem.FileOpen(1, FileName, OpenMode.Binary)
sText = FileSystem.InputString(1, FileSystem.LOF(1))
FileSystem.FileClose(1)
'Start document'
vp.StartDoc()
vp.Paragraph = sText
vp.Text = Environment.NewLine & "This is a test of vsPrinter Text property!"
'appends to exisitng text.'
vp.EndDoc()
End Sub
19.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 RenderFile()
' Set up the document'
vp.DocName = "VSPrinter Sample"
vp.Header = "Sample||Page %d"
vp.Footer = Format(Now, "dd-mmm-yy") & "||" & FileName
vp.PageBorder = pbAll
'Read file'
Dim sText As String
Open FileName For Binary As #1
sText = Input$(LOF(1), 1)
Close #1
'Start document'
vp.StartDoc
vp.Paragraph = sText
vp.Text = vbNewLine & "This is a test of vsPrinter Text property!"
'appends to exisitng text.'
vp.EndDoc
End Sub
C# code:
private void RenderFile()
{
// Set up the document
vp.DocName = "VSPrinter Sample";
vp.Header = "Sample||Page %d";
vp.Footer = DateTime.Now.ToString("dd-MMM-yy") + "||" + FileName;
vp.PageBorder = VSPrinter8Lib.PageBorderSettings.pbAll;
//Read file
string sText = "";
FileSystem.FileOpen(1, FileName, OpenMode.Binary, OpenAccess.Default, OpenShare.Default, -1);
sText = FileSystem.InputString(1, (int) FileSystem.LOF(1));
FileSystem.FileClose(1);
//Start document
vp.StartDoc();
vp.Paragraph = sText;
vp.CtlText = Environment.NewLine + "This is a test of vsPrinter Text property!";
//appends to exisitng text.
vp.EndDoc();
}
VB.NET code:
Private Sub RenderFile()
' Set up the document'
vp.DocName = "VSPrinter Sample"
vp.Header = "Sample||Page %d"
vp.Footer = DateTime.Now.ToString("dd-MMM-yy") & "||" & FileName
vp.PageBorder = VSPrinter8Lib.PageBorderSettings.pbAll
'Read file'
Dim sText As String = ""
FileSystem.FileOpen(1, FileName, OpenMode.Binary)
sText = FileSystem.InputString(1, FileSystem.LOF(1))
FileSystem.FileClose(1)
'Start document'
vp.StartDoc()
vp.Paragraph = sText
vp.CtlText = Environment.NewLine & "This is a test of vsPrinter Text property!"
'appends to exisitng text.'
vp.EndDoc()
End Sub
20. WshRuntimeLib
20.1. To Microsoft.Win32.RegistryKey helper class
Convert the registry operations of IWshRuntimeLib to Microsoft.Win32.RegistryKey by using some helpers.
Original VB6 code:
Dim EXAMPLE_KEYVALUE_NAME As String
EXAMPLE_KEYVALUE_NAME = "HKLM\Example\KeyName\ValueName"
Dim objWScriptShell As IWshRuntimeLibrary.IWshShell
Set objWScriptShell = New IWshRuntimeLibrary.IWshShell_Class
objWScriptShell.RegWrite EXAMPLE_KEYVALUE_NAME, "example data value", "REG_SZ"
Dim regDataValue As Variant
regDataValue = objWScriptShell.RegRead(EXAMPLE_KEYVALUE_NAME)
objWScriptShell.RegDelete EXAMPLE_KEYVALUE_NAME
Dim EXAMPLE_KEYVALUE_NAME As String = "HKLM\Example\KeyName\ValueName"
Dim objWScriptShell As IWshRuntimeLibrary.IWshShell = New IWshRuntimeLibrary.WshShell()
RegistryHelper.RegWriteValue(EXAMPLE_KEYVALUE_NAME, "example data value", "REG_SZ")
Dim regDataValue As Object = RegistryHelper.RegReadDataValue(EXAMPLE_KEYVALUE_NAME)
RegistryHelper.RegDeleteValue(EXAMPLE_KEYVALUE_NAME)
20.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:
Dim EXAMPLE_KEYVALUE_NAME As String
EXAMPLE_KEYVALUE_NAME = "HKLM\Example\KeyName\ValueName"
Dim objWScriptShell As IWshRuntimeLibrary.IWshShell
Set objWScriptShell = New IWshRuntimeLibrary.IWshShell_Class
objWScriptShell.RegWrite EXAMPLE_KEYVALUE_NAME, "example data value", "REG_SZ"
Dim regDataValue As Variant
regDataValue = objWScriptShell.RegRead(EXAMPLE_KEYVALUE_NAME)
objWScriptShell.RegDelete EXAMPLE_KEYVALUE_NAME
Dim EXAMPLE_KEYVALUE_NAME As String = "HKLM\Example\KeyName\ValueName"
Dim objWScriptShell As IWshRuntimeLibrary.IWshShell = New IWshRuntimeLibrary.WshShell()
objWScriptShell.RegWrite(EXAMPLE_KEYVALUE_NAME, "example data value", "REG_SZ")
Dim regDataValue As Object = objWScriptShell.RegRead(EXAMPLE_KEYVALUE_NAME)
objWScriptShell.RegDelete(EXAMPLE_KEYVALUE_NAME)
21. XArray
21.1. To System.Array
Convert Apex XArrayObject to .NET as a System.Array.
This option converts XArray objects to .NET as a System.Array.
The VBUC supports APEX Control version 1.0.007
General Description:
The XArray object allows users to create arrays with any bounds that you want. For instance, an XArray can be declared with its lower bound starting at 5 or 1000. This kind of array declaration is not supported because .NET arrays are always zero-based.
Original VB6 code:
Dim aTest(1 To 2) As New XArrayObject.XARRAY
Dim lTestP As Variant
lTestP = aTest.Count(0)
lTestP = aTest(0, 0, 0).Value(0)
lTestP = aTest(0, 0, 0).Value(0, 1, 2, 3)
Imports System
Dim aTest() As Array = ArraysHelper.InitializeArray(Of Array)(2)
Dim lTestP As Object
ReflectionHelper.SetPrimitiveValue(lTestP, aTest(0, 0, 0).GetValue(0))
ReflectionHelper.SetPrimitiveValue(lTestP, aTest(0, 0, 0).GetValue(0, 1, 2, 3))
21.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:
Dim aTest(1 To 2) As New XArrayObject.XARRAY
Dim lTestP As Variant
lTestP = aTest.Count(0)
lTestP = aTest(0, 0, 0).Value(0)
lTestP = aTest(0, 0, 0).Value(0, 1, 2, 3)
Dim aTest() As XArrayObject.XArray = ArraysHelper.InitializeArray(Of XArrayObject.XArray)(2)
ReflectionHelper.SetPrimitiveValue(lTestP, aTest(0, 0, 0).get_Value(0))
ReflectionHelper.SetPrimitiveValue(lTestP, aTest(0, 0, 0).get_Value(0, 1, 2, 3))
22. XArrayDB
22.1. To System.Data.DataTable helper class
The migrated code may change depending on the use in Visual Basic 6.
General Description:
The XArrayDB object implements a two-dimensional array of arbitrary variants. XArrayDB objects automatically shift their contents when rows (or columns) are inserted or deleted. Also, the XArrayDB object is used as a data source for a ComponentOne True DBGrid control in storage mode. You can even use XArrayDB outside the context of True DBGrid, as it is packaged as a separate file, XADB8.OCX, which is not dependent on any of the grid .OCX files.
The XArray object can be upgraded to .NET as a System.Array. However, if this object is used to populate an ActiveX TrueDBGrid control, this approach does not work when the TrueDBGrid is converted to a .NET equivalent, because bindable .NET controls must be linked to controls that implement the IListSource interface such as DataSets or DataTables.
The Visual Basic Upgrade Companion assumes XArrayDbObjects are used for managing a two dimensions array. XArrayDBObjects are converted to a Support class that inherits from System.Data.DataTable class.
Original VB6 code:
'General declarations'
Dim x As New XArrayDB
'Allocate space for 100 rows, 4 columns'
x.ReDim 0, 99, 0, 3
'Bind True DBGrid Control to this XArray instance'
Set TDBGrid1.Array = x
C# code:
public class XArray : System.Data.DataTable
Member of UpgradeHelpers.XArray.VBUtils
//General declarations
private VBUtils.XArray _x = null;
VBUtils.XArray x{
get{
if (_x == null){
_x = new VBUtils.XArray();
}
return _x;
}set{
_x = value;
}
}
//Allocate space for 100 rows, 4 columns
x.RedimXArray(new int[]{99, 3}, new int[]{0, 0});
//Bind True DBGrid Control to this XArray instance
TDBGrid1.Array = x;
VB.NET code:
Public Class XArray
Inherits System.Data.DataTable
Member of VBUtils
'General declarations'
Private _x As VBUtils.XArray = Nothing
Property x() As VBUtils.XArray
Get
If _x Is Nothing Then
_x = New VBUtils.XArray()
End If
Return _x
End Get
Set(ByVal Value As VBUtils.XArray)
_x = Value
End Set
End Property
'Allocate space for 100 rows, 4 columns'
x.RedimXArray(New Integer() {99, 3}, New Integer() {0, 0})
'Bind True DBGrid Control to this XArray instance'
TDBGrid1.Array = x
22.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:
'General declarations'
Dim x As New XArrayDB
'Allocate space for 100 rows, 4 columns'
x.ReDim 0, 99, 0, 3
'Bind True DBGrid Control to this XArray instance'
Set TDBGrid1.Array = x
C# code:
public interface XArrayDB
Member of Assembly Interop.XArrayDBObject
//General declarations
private XArrayDBObject.XArrayDB _x = null;
XArrayDBObject.XArrayDB x{
get{
if (_x == null){
_x = new XArrayDBObject.XArrayDB();
}
return _x;
}set{
_x = value;
}
}
//Allocate space for 100 rows, 4 columns
x.ReDim(0, 99, 0, 3);
//Bind True DBGrid Control to this XArray instance
TDBGrid1.Array = x;
VB.NET code:
Namespace XArrayDBObject
Member of Interop.XArrayDBObject
'General declarations'
Private _x As XArrayDBObject.XArrayDB = Nothing
Property x() As XArrayDBObject.XArrayDB
Get
If _x Is Nothing Then
_x = New XArrayDBObject.XArrayDB()
End If
Return _x
End Get
Set(ByVal Value As XArrayDBObject.XArrayDB)
_x = Value
End Set
End Property
'Allocate space for 100 rows, 4 columns'
x.ReDim(0, 99, 0, 3)
'Bind True DBGrid Control to this XArray instance'
TDBGrid1.Array = x