Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / May 2007

Tip: Looking for answers? Try searching our database.

Can someone translate this to vb.net?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
raz230 - 24 May 2007 04:51 GMT
I'm sorry for posting this here-

I have to integrate an parcel tracking with Canada Post into one of my
applications.  The web service they use is made with SAP and is not
the usual WSDL type of service I am used to.  I cannot just add a web
reference to my project and get going.

Canada Post provides a sample in Java and C# - and I do not know
either.

If it's not too hard, is anyone able to translate this into VB.net?

        static void Main(string[] args)
        {
            try
            {
WebReference.ZWBRAND_REQUESTEDPINS_LN[] requestPins = new
WebReference.ZWBRAND_REQUESTEDPINS_LN[1];

            requestPins[0]= new WebReference.ZWBRAND_REQUESTEDPINS_LN();

WebReference.ZDC_GET_HISTORYService tandtService = new
WebReference.ZDC_GET_HISTORYService();

            NetworkCredential UserInfo= new NetworkCredential("MY USER ID", "MY
PASSWORD");

            tandtService.Credentials=UserInfo;

            //Populate Pin information
            requestPins[0].PIN="CH000862116CA";
            requestPins[0].FSA="";

            //Set-up call and execute service
WebReference.ZWBRAND_CPCRESPONSE tandtResponse =
tandtService.ZDC_GET_HISTORY("N", requestPins, "1", "JKL", "Y");
            //Get a handle on response pin information
            WebReference.ZWBRAND_PINS_LN[] responsePins =
tandtResponse.PINS;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
            }
        }

Huge thanks and sorry if this is asking alot- I just have no clue
about C#...

Raz
Alberto Poblacion - 24 May 2007 06:43 GMT
> [...]
> Can someone translate this to vb.net?

There are various translators that can automatically convert from C# to
VB.Net and viceversa. For example, the one at
http://www.developerfusion.co.uk/utilities/convertcsharptovb.aspx provides
this translation for your code fragment:

Shared Sub Main(ByVal args As String())
Try
  Dim requestPins(1) As WebReference.ZWBRAND_REQUESTEDPINS_LN
  requestPins(0) = New WebReference.ZWBRAND_REQUESTEDPINS_LN
  Dim tandtService As WebReference.ZDC_GET_HISTORYService = New
WebReference.ZDC_GET_HISTORYService
  Dim UserInfo As NetworkCredential = New NetworkCredential("MY USER ID",
"MY PASSWORD")
  tandtService.Credentials = UserInfo
  requestPins(0).PIN = "CH000862116CA"
  requestPins(0).FSA = ""
  Dim tandtResponse As WebReference.ZWBRAND_CPCRESPONSE =
tandtService.ZDC_GET_HISTORY("N", requestPins, "1", "JKL", "Y")
  Dim responsePins As WebReference.ZWBRAND_PINS_LN() = tandtResponse.PINS
Catch ex As Exception
  Console.WriteLine(ex.StackTrace)
End Try
End Sub
raz230 - 31 May 2007 15:24 GMT
On May 24, 12:43 am, "Alberto Poblacion" <earthling-
quitaestoparacontes...@poblacion.org> wrote:

> > [...]
> > Can someone translate this to vb.net?
[quoted text clipped - 21 lines]
>  End Try
> End Sub

Perfect - thanks very much!
David Anton - 24 May 2007 15:05 GMT
The other conversion will not work - array declarations use the upper bound
in VB, while C# uses length (these are always 1-off).

(the following is produced by Instant VB):
Shared Sub Main(ByVal args As String())
    Try
        Dim requestPins As WebReference.ZWBRAND_REQUESTEDPINS_LN() = New
WebReference.ZWBRAND_REQUESTEDPINS_LN(0){}

        requestPins(0)= New WebReference.ZWBRAND_REQUESTEDPINS_LN()

        Dim tandtService As WebReference.ZDC_GET_HISTORYService = New
WebReference.ZDC_GET_HISTORYService()

        Dim UserInfo As NetworkCredential= New NetworkCredential("MY USER ID", "MY
PASSWORD")

        tandtService.Credentials=UserInfo

        'Populate Pin information
        requestPins(0).PIN="CH000862116CA"
        requestPins(0).FSA=""

        'Set-up call and execute service
        Dim tandtResponse As WebReference.ZWBRAND_CPCRESPONSE =
tandtService.ZDC_GET_HISTORY("N", requestPins, "1", "JKL", "Y")
        'Get a handle on response pin information
        Dim responsePins As WebReference.ZWBRAND_PINS_LN() = tandtResponse.PINS
    Catch ex As Exception
        Console.WriteLine(ex.StackTrace)
    End Try
End Sub

Signature

David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
C++ to C# Converter: converts C++ to C#
Instant C++: converts C# or VB to C++/CLI

> I'm sorry for posting this here-
>
[quoted text clipped - 46 lines]
>
> Raz

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.