?
Solved

Translation of C# array to VB.NET

Posted on 2008-10-28
6
Medium Priority
?
240 Views
Last Modified: 2008-10-28
Hi there.
I need some help translating the following small snippet from C# to VB.NET. Unfortunately I am totaly lost when it comes to C# and this time it is the array that is confusing.

Probably easy for you guys, but hard for me. ;)

Thanks in advance!
//Purchase list (catalog purchases)
if(PRP_CatalogPurchases != null)
{
   for(int i = 0;i < PRP_CatalogPurchases.Count;i++)
   {
   string[] Purchase = (string[])PRP_CatalogPurchases[i];
   PRP_XmlData += "<catalog_purchase>" + Environment.NewLine;
   PRP_XmlData += "<line_number>" +  PRP_htmlspecialchars((string)Purchase[0]) + "</line_number>" + Environment.NewLine;
   PRP_XmlData += "<id>" +  PRP_htmlspecialchars((string)Purchase[1]) + "</id>" + Environment.NewLine;
   PRP_XmlData += "<quantity>" +  PRP_htmlspecialchars((string)Purchase[2]) + "</quantity>" + Environment.NewLine;
   PRP_XmlData += "</catalog_purchase>" + Environment.NewLine;
   }
}

Open in new window

0
Comment
Question by:JohnModig
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 8

Expert Comment

by:jorgesv13
ID: 22824947
Try:

 
    * 'Purchase list (catalog purchases)
    * If PRP_CatalogPurchases IsNot Nothing Then
    *     For i As Integer = 0 To PRP_CatalogPurchases.Count - 1
    *         Dim Purchase As String() = DirectCast(PRP_CatalogPurchases(i), String())
    *         PRP_XmlData += "<catalog_purchase>" + Environment.NewLine
    *         PRP_XmlData += "<line_number>" + PRP_htmlspecialchars(DirectCast(Purchase(0), String)) + "</line_number>" + Environment.NewLine
    *         PRP_XmlData += "<id>" + PRP_htmlspecialchars(DirectCast(Purchase(1), String)) + "</id>" + Environment.NewLine
    *         PRP_XmlData += "<quantity>" + PRP_htmlspecialchars(DirectCast(Purchase(2), String)) + "</quantity>" + Environment.NewLine
    *         PRP_XmlData += "</catalog_purchase>" + Environment.NewLine
    *     Next
    * End If

Open in new window

0
 
LVL 48

Accepted Solution

by:
jpaulino earned 1000 total points
ID: 22824948
Try this way using http://www.developerfusion.com/tools/convert/csharp-to-vb/
'Purchase list (catalog purchases) 
If PRP_CatalogPurchases IsNot Nothing Then 
    For i As Integer = 0 To PRP_CatalogPurchases.Count - 1 
        Dim Purchase As String() = DirectCast(PRP_CatalogPurchases(i), String()) 
        PRP_XmlData += "<catalog_purchase>" + Environment.NewLine 
        PRP_XmlData += "<line_number>" + PRP_htmlspecialchars(DirectCast(Purchase(0), String)) + "</line_number>" + Environment.NewLine 
        PRP_XmlData += "<id>" + PRP_htmlspecialchars(DirectCast(Purchase(1), String)) + "</id>" + Environment.NewLine 
        PRP_XmlData += "<quantity>" + PRP_htmlspecialchars(DirectCast(Purchase(2), String)) + "</quantity>" + Environment.NewLine 
        PRP_XmlData += "</catalog_purchase>" + Environment.NewLine 
    Next 
End If 

Open in new window

0
 
LVL 8

Assisted Solution

by:jorgesv13
jorgesv13 earned 1000 total points
ID: 22824949
Sorry, here's formatted right:
'Purchase list (catalog purchases)
If PRP_CatalogPurchases IsNot Nothing Then
    For i As Integer = 0 To PRP_CatalogPurchases.Count - 1
        Dim Purchase As String() = DirectCast(PRP_CatalogPurchases(i), String())
        PRP_XmlData += "<catalog_purchase>" + Environment.NewLine
        PRP_XmlData += "<line_number>" + PRP_htmlspecialchars(DirectCast(Purchase(0), String)) + "</line_number>" + Environment.NewLine
        PRP_XmlData += "<id>" + PRP_htmlspecialchars(DirectCast(Purchase(1), String)) + "</id>" + Environment.NewLine
        PRP_XmlData += "<quantity>" + PRP_htmlspecialchars(DirectCast(Purchase(2), String)) + "</quantity>" + Environment.NewLine
        PRP_XmlData += "</catalog_purchase>" + Environment.NewLine
    Next
End If

Open in new window

0
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 
LVL 48

Expert Comment

by:jpaulino
ID: 22824952
Same tool jorgesv13 :)
0
 
LVL 8

Expert Comment

by:jorgesv13
ID: 22825049
Yep, that page rocks! :)
0
 
LVL 11

Author Comment

by:JohnModig
ID: 22825153
Oh, that was fast! Thank you guys. For the link as well. ;)
0

Featured Post

DFW AZURE MEETUP TONIGHT FRI 6PM

We will be discussing what Azure Stack is, how does it fit into the suit of offerings that Azure has currently, and where can it fit into your organizations technology stack. We will also be discussing limitations of the platform while covering various applicable scenarios.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question