Help converting C# code to VB


G

Guest

I am trying to convert the following to VB:

Imports System.Data
Imports System.Data.SqlClient
Imports System.Net
Imports System.IO.Stream

'Get the stream containing content returned by the server.
Dim dataStream = response.GetResponseStream()

'Open the stream using a StreamReader for easy access.
Dim reader = New StreamReader(dataStream) ---error
StreamReader not defined

'Read the content.
string[] responseFromServer = reader.ReadToEnd ().Split(',')
--not sure how to conver string[]

If (responseFromServer.Length <> 6) Then
Return
End If

me.txtLon.Text = responseFromServer[1]
me.txtLat.Text = responseFromServer[0]

Thanks.
 
Ad

Advertisements

C

Cor Ligthert [MVP]

Phil,

This is very basic Visual Basic Net code about the differences, however I do
it inline.
Imports System.Data
Imports System.Data.SqlClient
Imports System.Net
Imports System.IO.Stream

'Get the stream containing content returned by the server.
Dim dataStream = response.GetResponseStream()

'Open the stream using a StreamReader for easy access.
Dim reader = New StreamReader(dataStream) ---error
Dir reader As New StreamReader(DataStream)
'Read the content.
string[] responseFromServer = reader.ReadToEnd ().Split(',')
dim responseFromServer as string() =
If (responseFromServer.Length <> 6) Then
Return
in a Sub
End Sub
End If

me.txtLon.Text = responseFromServer[1]
me.txtLat.Text = responseFromServer[0]
me.textLat.Text = responseFromServer(0) 'the first element from the spitted
string

Code C# and VB
http://www.harding.edu/USER/fmccown/WWW/vbnet_csharp_comparison.html

Language compare
http://msdn.microsoft.com/library/en-us/vsintro7/html/vxgrfLanguageEquivalents.asp

Something about C# written by a C# adept
http://www.pobox.com/~skeet/csharp/faq/#vb.or.csharp

I hope this helps a little bit?

Cor

I hope this helps,

Cor
 
H

Herfried K. Wagner [MVP]

Phill said:
I am trying to convert the following to VB:
Imports System.IO.Stream
.... should read 'Imports System.IO'.
'Open the stream using a StreamReader for easy access.
Dim reader = New StreamReader(dataStream) ---error
StreamReader not defined
.... should read 'Dim Reader As New StreamReader(DataStream)'.

'Read the content.
string[] responseFromServer = reader.ReadToEnd ().Split(',')
--not sure how to conver string[]
\\\
Dim Response() As String = Reader.ReadToEnd().Split(","c)
///
me.txtLon.Text = responseFromServer[1]
me.txtLat.Text = responseFromServer[0]
.... should read '... = ResponseFromServer(1)' and '... =
ResponseFromServer(0)' respectively.
 
Ad

Advertisements

C

Cor Ligthert [MVP]

David,

I was glad that Herfried did not give references to converters.

I surely would have written to him that this code should be done without a
converter even as it was alone to learn from it. As me he understood that
probably.

Just my thought,

Cor

David Anton said:
Which converter did you use?
--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C# to C++ converter
Instant C++: VB to C++ converter


Phill said:
I am trying to convert the following to VB:

Imports System.Data
Imports System.Data.SqlClient
Imports System.Net
Imports System.IO.Stream

'Get the stream containing content returned by the server.
Dim dataStream = response.GetResponseStream()

'Open the stream using a StreamReader for easy access.
Dim reader = New StreamReader(dataStream) ---error
StreamReader not defined

'Read the content.
string[] responseFromServer = reader.ReadToEnd ().Split(',')
--not sure how to conver string[]

If (responseFromServer.Length <> 6) Then
Return
End If

me.txtLon.Text = responseFromServer[1]
me.txtLat.Text = responseFromServer[0]

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top