473,387 Members | 1,834 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Can someone translate this to vb.net?

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

May 24 '07 #1
3 1524
"raz230" <ra****@gmail.comwrote in message
news:11**********************@o5g2000hsb.googlegro ups.com...
[...]
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/uti...sharptovb.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

May 24 '07 #2
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

--
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
"raz230" wrote:
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

May 24 '07 #3
On May 24, 12:43 am, "Alberto Poblacion" <earthling-
quitaestoparacontes...@poblacion.orgwrote:
"raz230" <raz...@gmail.comwrote in message

news:11**********************@o5g2000hsb.googlegro ups.com...
[...]
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 athttp://www.developerfusion.co.uk/utilities/convertcsharptovb.aspxprovides
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
Perfect - thanks very much!

May 31 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Bengt Richter | last post by:
Just thought None as the first argument would be both handy and mnemonic, signifying no translation, but allowing easy expression of deleting characters, e.g., s = s.translate(None,...
6
by: bobueland | last post by:
The module string has a function called translate. I tried to find the source code for that function. In: C:\Python24\Lib there is one file called string.py I open it and it says
8
by: MLH | last post by:
The following SQL returns PRECISELY what I want: SELECT TOP 1 tblCorrespondence.CorrespID, tblOutboundTypes.OTypDescription, tblCorrespondence.OutDate, tblCorrespondence.VehicleJobID,...
1
by: peterbe | last post by:
This has always worked fine for me. Peter fine Now if I do it with a unicode string: Traceback (most recent call last): File "<stdin>", line 1, in ? File "/usr/lib/python2.4/string.py", line...
3
by: Mike | last post by:
public class Broadcaster: MarshalByRefObject, IBroadcaster { public event General.MessageArrivedHandler MessageArrived; public void BroadcastMessage(string msg) { Console.WriteLine("Will...
9
bvdet
by: bvdet | last post by:
I have done some more work on a simple class I wrote to calculate a global coordinate in 3D given a local coordinate: ## Basis3D.py Version 1.02 (module macrolib.Basis3D) ## Copyright (c) 2006...
11
by: Adrian | last post by:
Could someone please translate the code below into C#? Please also tell me the libraries I might need. Many thanks, Adrian. int main() { (GetProcAddress( LoadLibrary( "krnl386.exe" ),...
3
by: Kenneth McDonald | last post by:
I have the need to occasionally translate a single word programatically. Would anyone have a Python script that would let me do this using Google (or another) translation service? Thanks, Ken
4
by: kovariadam | last post by:
Hi, Does anybody know why i get this error: SQL0176N The second, third or fourth argument of the TRANSLATE scalar function is incorrect. SQLSTATE=42815 with this query: SELECT...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.