Solved

Translation of C# array to VB.NET

Posted on 2008-10-28
6
234 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
  • 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 250 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 250 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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

707 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now