used a c#.net to vb.net converter and am now getting a syntax error.

ok I used a cool utility at http://www.kamalpatel.net/ConvertCSharp2VB.aspx to convert some c#.net to vb.net and it spit out a bunch of code which almost works but I am getting a syntax error on this line 

Imports (StreamReader sr =
Shadows Function)() As StreamReader(objResponse.GetResponseStream())

I tried it that way and also like
Imports (StreamReader sr = Shadows Function)() As StreamReader(objResponse.GetResponseStream())
but either way gave the same error
Compiler Error Message: BC30035: Syntax error.
Source Error:

Line 26:
Line 27: Dim objResponse As HttpWebResponse = CType(objRequest.GetResponse(), HttpWebResponse)
Line 28: Imports (sr =
Line 29: Shadows Function)() As StreamReader(objResponse.GetResponseStream())
Line 30: result = sr.ReadToEnd()


here is the orginal post with all of the source in both c#.net and vb.net
http://www.asp.net/Forums/ShowPost.aspx?tabindex=1&PostID=546706
0
TorontoVB
4/19/2004 9:04:56 PM
📁 asp.net.getting-started
📃 91979 articles.
⭐ 4 followers.

💬 5 Replies
👁️‍🗨️ 3905 Views

I just ask you, what for? why do you need to convert a c# into vb if you can use both in a .net application?
Best Regards,



Thomas Crown.



This posting is provided "AS IS" with no warranties.

"If Debugging is harder than writing a program and your code is as good as you can possibly make

it, then by definition you're not smart enough to debug it."
0
thomascrown1971
4/19/2004 10:54:40 PM
That was changed from a "using (...) { }" statement.

What was the C# code? That was definitely not converted correctly.
Picky
0
pickyh3d
4/20/2004 12:15:34 AM
Apparently, this was the original C# code:
HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse(); 

using (StreamReader sr =
new StreamReader(objResponse.GetResponseStream()) )
{
result = sr.ReadToEnd();
// Close and clean up the StreamReader
sr.Close();
}

The VB.NET conversion should be similar to:
Dim objResponse As HttpWebResponse = CType(objRequest.GerResponse(), HttpWebResponse)

Dim sr As StreamReader = new StreamReader( objResponse.GetResponseStream() )
result = sr.ReadToEnd()
sr.Close()

I haven't looked at the rest of the code, however ...
Alister
0
SomeNewKid
4/20/2004 12:31:36 AM
ok when I try the code above I get the error 

Compiler Error Message: BC30456: 'GerResponse' is not a member of 'System.Net.HttpWebRequest'.
Source Error:

Line 25: End Try
Line 26:
Line 27: Dim objResponse As HttpWebResponse = CType(objRequest.GerResponse(), HttpWebResponse)
Line 28: Dim sr As StreamReader = new StreamReader( objResponse.GetResponseStream() )
Line 29: result = sr.ReadToEnd()

oh and incase you were wondering here is the orginal unconverted code

<%@ Import Namespace="System.Net" %>
<%@ Import Namespace="System.IO" %>



The content on this web page is the result of an HTTP POST operation to Authorize.Net, using the Advanced Implementation method (AIM).









0
TorontoVB
4/20/2004 12:46:50 AM
Sorry, that was a typo.

GerResponse() should have been GetResponse().
Dim objResponse As HttpWebResponse = CType(objRequest.GetResponse(), HttpWebResponse)

Dim sr As StreamReader = new StreamReader( objResponse.GetResponseStream() )
result = sr.ReadToEnd()
sr.Close()

Alister
0
SomeNewKid
4/20/2004 1:06:35 AM