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. 3 followers. Follow

5 Replies
1896 Views

Similar Articles

[PageSpeed] 10

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" %>
<script language="C#" runat="server">
void Page_Load(Object Src, EventArgs E) {
myPage.Text = readHtmlPage("https://certification.authorize.net/gateway/transact.dll");
}
private String readHtmlPage(string url)
{
String result = "";
String strPost = "x_login=YOUR-LOG-IN-ID&x_tran_key=YOUR-TRANSACTION-KEY&x_method=CC&x_type=AUTH_CAPTURE&x_amount=1.00&x_delim_data=TRUE&x_delim_char=|&x_relay_response=FALSE&x_card_num=4111111111111111&x_exp_date=052005&x_test_request=TRUE&x_version=3.1";
StreamWriter myWriter = null;

HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url);
objRequest.Method = "POST";
objRequest.ContentLength = strPost.Length;
objRequest.ContentType = "application/x-www-form-urlencoded";

try
{
myWriter = new StreamWriter(objRequest.GetRequestStream());
myWriter.Write(strPost);
}
catch (Exception e)
{
return e.Message;
}
finally {
myWriter.Close();
}

HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse();
using (StreamReader sr =
new StreamReader(objResponse.GetResponseStream()) )
{
result = sr.ReadToEnd();
// Close and clean up the StreamReader
sr.Close();
}
return result;
}
</script>
<html>
<body>
The content on this web page is the result of an HTTP POST operation to Authorize.Net, using the Advanced Implementation method (AIM).<br>
<br/>
<hr/>
<asp:literal id="myPage" runat="server"/>
</body>
</html>

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
Reply:

Similar Artilces:

Sending SMS using vb.net or C#.net using vb.net or c#.net
Hi  My requirement is I hav one csv file with these fields id,mobilenum,messgae,status.intiallu staus is 0. once i read the all fileds and take that mobile number.using tat mobile number  i need to send sms .after sending sms i shuld change status as 1 How to send sms thru coding (please dont provide any links.if it is provide also please give working links becox i checked codeproject .i didnt get any nice link. and also provide the how to update the status field im csv file   Thank ssandhya   To send SMS, you need some third party SMS providers. if you consul...

use VB.NET and C#.NET code in the same C#.NET project
All-- Here is a sample that is "off the beaten path", (at least for me). Is it possible, in an ASP.NET application, using the code-behind page building technique, to have both pages written in VB.NET and pages written C#.NET?At http://www.WebLogicArts.com/DemoList.aspx there is a sample that shows that, (contrary to popular belief), it IS possible to mix ASP.NET pages built with C#.NET with ASP.NET pages built with VB.NET in the same VS.NET 2003 project. Note that this is just a "fun" sample to see if it can be done and I do not recommend this practice as a "standard" way of develo...

converting to vb.net from c#.net authorize.net
authorize.net offered me some sample code when I signed up with them the only problem is the sample code is in c#.net but my page that they type all of their credit card into is vb.net <code><%@ Import Namespace="System.Net" %> <%@ Import Namespace="System.IO" %> <script language="C#" runat="server"> void Page_Load(Object Src, EventArgs E) { myPage.Text = readHtmlPage("https://certification.authorize.net/gateway/transact.dll"); } private String readHtmlPage(string url) { ...

Get help from VB.NET & C# syntax convertion
Anyone can help to convert below C# code to VB.NET ASAP, thanks! string speechServer = ConfigurationSettings.AppSettings["SpeechServer"]; Param param = new Param(); param.Name = "server"; param.Value = speechServer; Prompt1.Params.Add(param);   Here's the VB.NET conversion: Dim speechServer As String = ConfigurationSettings.AppSettings("SpeechServer") Dim param As New Param()param.Name = "server"param.Value = speechServer Prompt1.Params.Add(param)Ryan OlshanASPInsider | Microsoft MVP, ASP.NEThttp://ryanolshan.comHow to ask a question Also you can use Kamal's C# to...

Converting from vb.net to c#.net
Hello I have recently purchased VBGolds RawDataPrinter which should allow users to print directly to label printers on our network directly from a c# web form.  Unfortunately they only supply vb.net examples and I have need of c#.  The component has been installed on our web server.  This is some code that they have supplied as examples in vb.net   "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" >"Head1" runat="server&qu...

use of vb.net and c#.net
i make a small website using vb.net,  in it i make a 2 class in C#.net. that i want to use in that website, i dont know how to call that class. let your class is  - class clsMyClass    {        public void myFunction()        {            // do something        }    } now the first way - create objectclsMyClass myObj = new clsMyClass();myObj.myFunction(); // call function================...

Converting classic to .NET 2 code, and .NET gets an error back from ADS?
 For future-proofing, our Internal Phone Directory is being moved onto our AD servers, and obviously we're using LDAP for queries.To get the phoneboook queries working, I adapted the current classic ASP code to use LDAP, and that works fine. However, we're wanting to move these pages to .NET, and that's where the problem comes in. Using the same basic logic from the Classic code (90% of its unchanged) to produce an LDAP query, I get the error  155 Unknown error (0x80005000)This is using the same website, and so the same credentials  - unless aspx pages run und...

Developed C#.net WebService 1.1 for Client C#.net 1.1. Getting error "Server was unable to process the Request" Pls Help
Hi., I developed Microsoft C#.net Web Services2003 for the Client Application C#.net 2003. When it runs in 5 machines it gives good performance and has no errors. But if i run the same application in about 80 client machines. Getting error "Server was unable to process the request". I use Sql Server 2005 as my database. I get error even when i login at a time for about 25 users. Tried modifying machine.config too. But went unsuccessful. Live Server is 2003 using IIS 6.0 I use very expensive data handling.  Its very urgent pls help. Have to post in Live Server. Thank u., ...

convert c#.net page to vb.net
ok I have an entire page in vb.net and now I want to integrate some code from another page but it written in c#.net what is the easiest way to convert c#.net to vb.net I tried using www.kamalpatel.net/ConvertCSharp2VB.aspx but it only gave me errors here is what I am trying to convert let me know if you have any ideas http://www.nomorepasting.com/paste.php?pasteID=20953 With Alex Lowe's translator ' Messages Private NoFileMessage As String = "No file selected" Private UploadSuccessMessage As String = "Uploaded Sucess" Private NoImagesMessag...

How to get RS (From VB6) to .NET (VB.NET)
Hi Friends,         I have requirement, there is one function in VB6 it returns a RS, I need to call that function in  VB.NET, how to get those values into .NET, if can any body can help (pass me some code snippets), that will be greate, Thank you.Madhu... -Madhu hey guys i got this one just by using fill method.-Madhu...

Convert VB.Net application to C#.net
Haican any one help me to convert VB.Net application in this link to C#.net http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=6718&lngWId=10RegardsAnu Palavila  Regards Anu Palavila Use this Free Conversion tool - http://www.developerfusion.com/tools/convert/vb-to-csharp/  ASP.NET Grid With Excel Capabilities | 27 GridView Tips & Tricks | Hosting your site? | SQL Server Tips Other Code Convertors (convert VB to C# and C# to VB) http://converter.telerik.com/ http://www.developerfusion.com/tools/convert/csharp-to-vb/ http://www.dotnetspider.com...

vb.net vs c#.net vs j#.net
just out of curiousity which looks, acts most like java? i'm still learning trying to used to vb.net but it seems that it was easier to do some stuff with java. C# is Java++ in my opinion. If you have done C or Jave you will prefer C#.Mike Schellenberger - MCAD If you are looking for language similar to java go for J#. However most code samples you find on the net will be in VB.NET and C#....

.Net 2.0 Web application using Vb.net is unable to create object of another dll writen in C# .net 2.0
Hi, I habe created one ASP.net web application using Vb.net which is adding reference of dlls written in C# and .net 2.0. But whenever trying to create object of referencing dll, it is throwing error :Object reference does not set to an object. But, locally it is working fine,. In the server i have deployed the .aspx files and dll files in the bin. There were already an web.config in the server which is of .net 1.1. But checked it is retrieving value for that web.config correctly. Should i have to deply any other files and if not what can be the solution for this? Please help. Thanks, So...

vb .net or c# .net
I currently develop websites using php but have been requested to develop a site using asp.net. The question I have is for someone who knows php would it be better to transition to vb.net or c#.net? Thanks, Fr. Robert C# -> There is a converter that will transition about 60% or more of your PHP code to C#. Plus C# is closer to PHP than VB.NET.Jason N. GaylordASPInsider and Microsoft MVPhttp://jasongaylord.com...

Web resources about - used a c#.net to vb.net converter and am now getting a syntax error. - asp.net.getting-started

DC-to-DC converter - Wikipedia, the free encyclopedia
DC to DC converters are important in portable electronic devices such as cellular phones and laptop computers , which are supplied with power ...

Swim Time Converter on the App Store on iTunes
Get Swim Time Converter on the App Store. See screenshots and ratings, and read customer reviews.

Pensioner with a gambling addiction taking payday lender Cash Converters to court
A disability support pensioner with a gambling addiction is taking Cash Converters to court, claiming it broke the law by repeatedly offering ...

Freemake Video Converter gains drag and drop support
Freemake Video Converter is a great media conversion tool with a pile of features, and just one small but annoying omission. No drag and drop ...

Amazon deal: Converter turns seven types of film into digital
... old film school projects from back in the day, but you don't have a film projector. The solution is simple: You should get a digital film converter ...

New catalytic converter could fix US cars: VW CEO
Volkswagen will propose to U.S. authorities a new catalytic converter system that could be fitted to about 430,000 cars.

VW wants to fix emissions cheating with catalytic converters
Volkswagen has already promised to recall US vehicles caught up in its emissions cheating scandal, but how is it actually going to fix most of ...

VW hopes catalytic converter can fix cars
German carmaker has devised tool that will make vehicles compliant with US clean air rules

Dos2Unix Text file format converters
Win32-OpenSSH - Win32 port of OpenSSH

News: MacX Video Converter Pro & WinX HD Video Converter Deluxe Giveaway
... editing in Final Cut Pro and iMovie, uploading to YouTube and Facebook and more. All Mac users can download a free copy of MacX Video Converter ...

Resources last updated: 1/13/2016 3:50:13 PM