Thanks goodness, VB.NET has almost nothing in common with VB6, there is only resemblance in very basic syntax. The paradigms are completely different, and target platforms are dramatically different. First of all, VB.NET is a fully-fledged object-oriented language and the .NET platform is truly object-oriented, too. (VB5 could be called "object-based" at best, which most crazy limitations.) While there is probably nothing good about VB6, VB.NET is a decent language (slightly behind C# in features), though absolutely not standard, in contrast to C# and C++/CLI which are standardized under ECMA and ISO.
So, it is amazing that Microsoft offers some automated migration method. However, from what I know, it's not too effective: for more or less complex project, some critical review of converted code and a good deal of manual work is unavoidable.
—SA
Updated 24-Nov-11 19:50pm
v2
Imports Microsoft.Office.InfoPath
Imports System
Imports System.Xml
Imports System.Xml.XPath
Imports IOP
Imports System.Data
Namespace Form1
Public Class FormCode
' Member variables are not supported in browser-enabled forms.
' Instead, write and read these values from the FormState
' dictionary using code such as the following:
'
' Private Property _memberVariable() As Object
' Get
' _memberVariable = FormState("_memberVariable")
' End Get
' Set
' FormState("_memberVariable") = value
' End Set
' End Property
' NOTE: The following procedure is required by Microsoft InfoPath.
' It can be modified using Microsoft InfoPath.
Private Sub InternalStartup(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Startup
AddHandler DirectCast(EventManager.ControlEvents("CTRL23_5"), ButtonEvent).Clicked, AddressOf CTRL23_5_Clicked
End Sub
Public Sub CTRL23_5_Clicked(ByVal sender As Object, ByVal e As ClickedEventArgs)
'declare Webswevice
Dim BudgetWS As New Budget.BudgetWS
'declare dataset
Dim dsTransactions As New DataSet
Dim dtTransactions As DataTable
Dim drTransactions As DataRow
' Dataset Coulmns
Dim clmID As DataColumn
Dim clmOperatingDate As DataColumn
Dim clmItemCode As DataColumn
Dim clmAssetCategoryID As DataColumn
Dim clmCompanyDescription As DataColumn
Dim clmPCGroup As DataColumn
Dim clmPCDesc As DataColumn
Dim clmCCGroup As DataColumn
Dim clmCCDesc As DataColumn
Dim clmQty As DataColumn
Dim clmCurrency As DataColumn
dtTransactions = New Data.DataTable()
clmID = New Data.DataColumn("ID", Type.GetType("System.Int32"))
clmOperatingDate = New Data.DataColumn("OperatingDate", Type.GetType("System.String"))
clmItemCode = New Data.DataColumn("ItemCode", Type.GetType("System.String"))
clmAssetCategoryID = New Data.DataColumn("AssetCategoryID", Type.GetType("System.String"))
clmCompanyDescription = New Data.DataColumn("CompanyDescription", Type.GetType("System.String"))
clmPCGroup = New Data.DataColumn("PCGroup", Type.GetType("System.String"))
clmPCDesc = New Data.DataColumn("PCDesc", Type.GetType("System.String"))
clmCCGroup = New Data.DataColumn("CCGroup", Type.GetType("System.String"))
clmCCDesc = New Data.DataColumn("CCDesc", Type.GetType("System.String"))
clmQty = New Data.DataColumn("Qty", Type.GetType("System.Decimal"))
clmCurrency = New Data.DataColumn("Currency", Type.GetType("System.String"))
dtTransactions.Columns.Add(clmID)
dtTransactions.Columns.Add(clmOperatingDate)
dtTransactions.Columns.Add(clmItemCode)
dtTransactions.Columns.Add(clmAssetCategoryID)
dtTransactions.Columns.Add(clmCompanyDescription)
dtTransactions.Columns.Add(clmPCGroup)
dtTransactions.Columns.Add(clmPCDesc)
dtTransactions.Columns.Add(clmCCGroup)
dtTransactions.Columns.Add(clmCCDesc)
dtTransactions.Columns.Add(clmQty)
dtTransactions.Columns.Add(clmCurrency)
'drTransactions = dtTransactions.NewRow()
'loop
Dim TableRows As XPathNodeIterator = Me.MainDataSource.CreateNavigator().Select("/my:myFields/my:group5/my:group6", NamespaceManager)
For i As Integer = 1 To TableRows.Count
Dim repTable As XPathNavigator = Me.MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:group5/my:group6[" & i & "]", NamespaceManager)
Dim nID As XPathNavigator = repTable.SelectSingleNode("my:ID", NamespaceManager) '/my:myFields/my:group5/my:group6/
Dim dtOperatingDate As XPathNavigator = repTable.SelectSingleNode("my:OperatingDate", NamespaceManager)
Dim nItemCode As XPathNavigator = repTable.SelectSingleNode("my:ItemCode", NamespaceManager)
Dim nAssetCategoryID As XPathNavigator = repTable.SelectSingleNode("my:AssetCategoryID", NamespaceManager)
Dim strCompanyDescription As XPathNavigator = repTable.SelectSingleNode("my:CompanyDescription", NamespaceManager)
Dim strPCGroup As XPathNavigator = repTable.SelectSingleNode("my:PCGroup", NamespaceManager)
Dim strPCDesc As XPathNavigator = repTable.SelectSingleNode("my:PCDesc", NamespaceManager)
Dim strCCGroup As XPathNavigator = repTable.SelectSingleNode("my:CCGroup", NamespaceManager)
Dim strCCDesc As XPathNavigator = repTable.SelectSingleNode("my:CCDesc", NamespaceManager)
Dim nQty As XPathNavigator = repTable.SelectSingleNode("my:Qty", NamespaceManager)
Dim nCurrency As XPathNavigator = repTable.SelectSingleNode("my:Currency", NamespaceManager)
drTransactions = dtTransactions.NewRow()
drTransactions("ID") = nID.Value
drTransactions("OperatingDate") = dtOperatingDate.Value
drTransactions("ItemCode") = nItemCode.Value
drTransactions("AssetCategoryID") = nAssetCategoryID.Value
drTransactions("CompanyDescription") = strCompanyDescription.Value
drTransactions("PCGroup") = strPCGroup.Value
drTransactions("PCDesc") = strPCDesc.Value
drTransactions("CCGroup") = strCCGroup.Value
drTransactions("CCDesc") = strCCDesc.Value
drTransactions("Qty") = nQty.Value
drTransactions("Currency") = nCurrency.Value
dtTransactions.Rows.Add(drTransactions)
Next
'---------------
dsTransactions.Tables.Add(dtTransactions)
BudgetWS.BudgetTransactionsInsertData(dsTransactions)
'XPathNavigator mainDataNavigator = MainDataSource.CreateNavigator();
' ' Get objects for the two value nodes hooked up to the data connection
' XPathNavigator employeeNode= mainDataNavigator.SelectSingleNode("create a field to hold the employee name value for the submit data connection and put its XPath here", NamespaceManager);
' XPathNavigator productNode = mainDataNavigator.SelectSingleNode("create a field to hold the product name and put its XPath here", NamespaceManager);
' Loop through each node of the repeating group
' foreach (XPathNavigator values in mainDataNavigator.Select("/dfs:myFields/dfs:dataFields/d:EE_Prod_Cat_Task", NamespaceManager))
' {
' // copy the values from this group's nodes to the submit fields
' employeeNode.SetValue(values.SelectSingleNode("d:Employee/@EmployeeName", NamespaceManager).Value);
' productNode.SetValue(values.SelectSingleNode("d:Product/@ProductName", NamespaceManager).Value);
' // Invoke the data connection
' DataConnections["Data_Submit"].Execute();
''modified code
''' Write your code here.
'Dim TableRows As XPathNodeIterator = Me.MainDataSource.CreateNavigator().Select("/my:myFields/my:testw", NamespaceManager)
'For i As Integer = 1 To TableRows.Count
' Dim repTable As XPathNavigator = Me.MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:testw[" & i & "]", NamespaceManager)
' Dim taskOwner As XPathNavigator = repTable.SelectSingleNode("my:TransDate", NamespaceManager)
' taskOwner.SetValue(taskOwner.Value.ToLower())
' DataConnections("Web Service Submit").Execute()
'original code
'' Write your code here.
'Dim TableRows As XPathNodeIterator = Me.MainDataSource.CreateNavigator().Select("/my:myFields/my:testw", NamespaceManager)
'For i As Integer = 1 To TableRows.Count
' Dim repTable As XPathNavigator = Me.MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:testw[" & i & "]", NamespaceManager)
' Dim taskOwner As XPathNavigator = repTable.SelectSingleNode("my:TransDate", NamespaceManager)
' 'Dim Field1 As XPathNavigator = Me.MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:field1", NamespaceManager)
' 'Field1.SetValue(taskOwner.Value.ToString())
' 'WebServiceConnection wsSubmit = (WebServiceConnection)Me.DataConnections["Web Service Submit"];
' 'DataConnections["Web Service Submit"].Execute();
' ' 'taskOwner.SetValue(taskOwner.Value.ToLower())
' DataConnections("Web Service Submit").Execute()
'Next
End Sub
End Class
End Namespace
'Public Sub CTRL23_5_Clicked(ByVal sender As Object, ByVal e As ClickedEventArgs)
' 'declare Webswevice
' Dim BudgetWS As New Budget.BudgetWS
' 'declare dataset
' Dim dsTransactions As New DataSet
' Dim dtTransactions As DataTable
' Dim drTransactions As DataRow
' ' Dataset Coulmns
' Dim clmID As DataColumn
' Dim clmOperatingDate As DataColumn
' Dim clmItemCode As DataColumn
' Dim clmAssetCategoryID As DataColumn
' Dim clmCompanyDescription As DataColumn
' Dim clmPCGroup As DataColumn
' Dim clmPCDesc As DataColumn
' Dim clmCCGroup As DataColumn
' Dim clmCCDesc As DataColumn
' Dim clmQty As DataColumn
' Dim clmCurrency As DataColumn
' dtTransactions = New Data.DataTable()
' clmID = New Data.DataColumn("ID", Type.GetType("System.Int32"))
' clmOperatingDate = New Data.DataColumn("OperatingDate", Type.GetType("System.String"))
' clmItemCode = New Data.DataColumn("ItemCode", Type.GetType("System.String"))
' clmAssetCategoryID = New Data.DataColumn("AssetCategoryID", Type.GetType("System.String"))
' clmCompanyDescription = New Data.DataColumn("CompanyDescription", Type.GetType("System.String"))
' clmPCGroup = New Data.DataColumn("PCGroup", Type.GetType("System.String"))
' clmPCDesc = New Data.DataColumn("PCDesc", Type.GetType("System.String"))
' clmCCGroup = New Data.DataColumn("CCGroup", Type.GetType("System.String"))
' clmCCDesc = New Data.DataColumn("CCDesc", Type.GetType("System.String"))
' clmQty = New Data.DataColumn("Qty", Type.GetType("System.Decimal"))
' clmCurrency = New Data.DataColumn("Currency", Type.GetType("System.String"))
' dtTransactions.Columns.Add(clmID)
' dtTransactions.Columns.Add(clmOperatingDate)
' dtTransactions.Columns.Add(clmItemCode)
' dtTransactions.Columns.Add(clmAssetCategoryID)
' dtTransactions.Columns.Add(clmCompanyDescription)
' dtTransactions.Columns.Add(clmPCGroup)
' dtTransactions.Columns.Add(clmPCDesc)
' dtTransactions.Columns.Add(clmCCGroup)
' dtTransactions.Columns.Add(clmCCDesc)
' dtTransactions.Columns.Add(clmQty)
' dtTransactions.Columns.Add(clmCurrency)
' drTransactions = dtTransactions.NewRow()
' 'loop
' Dim TableRows As XPathNodeIterator = Me.MainDataSource.CreateNavigator().Select("/my:myFields/my:group1", NamespaceManager)
' For i As Integer = 1 To TableRows.Count
' Dim repTable As XPathNavigator = Me.MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:group1[" & i & "]", NamespaceManager)
' Dim nID As XPathNavigator = repTable.SelectSingleNode("my:group2/my:ID", NamespaceManager)
' Dim dtOperatingDate As XPathNavigator = repTable.SelectSingleNode("my:group2/my:OperatingDate", NamespaceManager)
' Dim nItemCode As XPathNavigator = repTable.SelectSingleNode("my:group2/my:ItemCode", NamespaceManager)
' Dim nAssetCategoryID As XPathNavigator = repTable.SelectSingleNode("my:group2/my:AssetCategoryID", NamespaceManager)
' Dim strCompanyDescription As XPathNavigator = repTable.SelectSingleNode("my:group2/my:CompanyDescription", NamespaceManager)
' Dim strPCGroup As XPathNavigator = repTable.SelectSingleNode("my:group2/my:PCGroup", NamespaceManager)
' Dim strPCDesc As XPathNavigator = repTable.SelectSingleNode("my:group2/my:PCDesc", NamespaceManager)
' Dim strCCGroup As XPathNavigator = repTable.SelectSingleNode("my:group2/my:CCGroup", NamespaceManager)
' Dim strCCDesc As XPathNavigator = repTable.SelectSingleNode("my:group2/my:CCDesc", NamespaceManager)
' Dim nQty As XPathNavigator = repTable.SelectSingleNode("my:group2/my:Qty", NamespaceManager)
' Dim nCurrency As XPathNavigator = repTable.SelectSingleNode("my:group2/my:Currency", NamespaceManager)
' drTransactions("ID") = nID.Value
' drTransactions("OperatingDate") = dtOperatingDate.Value
' drTransactions("ItemCode") = nItemCode.Value
' drTransactions("AssetCategoryID") = nAssetCategoryID.Value
' drTransactions("CompanyDescription") = strCompanyDescription.Value
' drTransactions("PCGroup") = strPCGroup.Value
' drTransactions("PCDesc") = strPCDesc.Value
' drTransactions("CCGroup") = strCCGroup.Value
' drTransactions("CCDesc") = strCCDesc.Value
' drTransactions("Qty") = nQty.Value
' drTransactions("Currency") = nCurrency.Value
' dtTransactions.Rows.Add(drTransactions)
' Next
' '---------------
' dsTransactions.Tables.Add(dtTransactions)
' BudgetWS.BudgetTransactionsInsertData(dsTransactions)
' 'XPathNavigator mainDataNavigator = MainDataSource.CreateNavigator();
' ' ' Get objects for the two value nodes hooked up to the data connection
' ' XPathNavigator employeeNode= mainDataNavigator.SelectSingleNode("create a field to hold the employee name value for the submit data connection and put its XPath here", NamespaceManager);
' ' XPathNavigator productNode = mainDataNavigator.SelectSingleNode("create a field to hold the product name and put its XPath here", NamespaceManager);
' ' Loop through each node of the repeating group
' ' foreach (XPathNavigator values in mainDataNavigator.Select("/dfs:myFields/dfs:dataFields/d:EE_Prod_Cat_Task", NamespaceManager))
' ' {
' ' // copy the values from this group's nodes to the submit fields
' ' employeeNode.SetValue(values.SelectSingleNode("d:Employee/@EmployeeName", NamespaceManager).Value);
' ' productNode.SetValue(values.SelectSingleNode("d:Product/@ProductName", NamespaceManager).Value);
' ' // Invoke the data connection
' ' DataConnections["Data_Submit"].Execute();
' ''modified code
' ''' Write your code here.
' 'Dim TableRows As XPathNodeIterator = Me.MainDataSource.CreateNavigator().Select("/my:myFields/my:testw", NamespaceManager)
' 'For i As Integer = 1 To TableRows.Count
' ' Dim repTable As XPathNavigator = Me.MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:testw[" & i & "]", NamespaceManager)
' ' Dim taskOwner As XPathNavigator = repTable.SelectSingleNode("my:TransDate", NamespaceManager)
' ' taskOwner.SetValue(taskOwner.Value.ToLower())
' ' DataConnections("Web Service Submit").Execute()
' 'original code
' '' Write your code here.
' 'Dim TableRows As XPathNodeIterator = Me.MainDataSource.CreateNavigator().Select("/my:myFields/my:testw", NamespaceManager)
' 'For i As Integer = 1 To TableRows.Count
' ' Dim repTable As XPathNavigator = Me.MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:testw[" & i & "]", NamespaceManager)
' ' Dim taskOwner As XPathNavigator = repTable.SelectSingleNode("my:TransDate", NamespaceManager)
' ' 'Dim Field1 As XPathNavigator = Me.MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:field1", NamespaceManager)
' ' 'Field1.SetValue(taskOwner.Value.ToString())
' ' 'WebServiceConnection wsSubmit = (WebServiceConnection)Me.DataConnections["Web Service Submit"];
' ' 'DataConnections["Web Service Submit"].Execute();
' ' ' 'taskOwner.SetValue(taskOwner.Value.ToLower())
' ' DataConnections("Web Service Submit").Execute()
' 'Next
'End Sub
________________________________________
Notice: The transmitted information is intended only for the person or entity to which it is addressed. It may contain confidential and/or privileged material. Any review, retransmission, dissemination or any other use of or taking any action in reliance upon this information by persons or entities other than the intended recipient(s) is strictly prohibited. If you receive this information in error, please contact the sender and delete the material from your system immediately.