Need help with Conversion from C# to VB.net

R

Rob

Any idease on how to fix ?

The Code in C#

public void Load(string FileName)
{
LineToDraw l;
try
{
this.Clear(true);
StreamReader sr = new StreamReader(FileName);
string line;
while ((line = sr.ReadLine()) != null)
{
l = new LineToDraw();
string[] linesplit = line.Split(Delimiter.ToCharArray());
l.StartX = int.Parse(linesplit[0].ToString());
l.StartY = int.Parse(linesplit[1].ToString());
l.EndX = int.Parse(linesplit[2].ToString());
l.EndY = int.Parse(linesplit[3].ToString());
Points.Add(l);
}
sr.Close();
}
catch (Exception) { throw; }
}

The code translated into VN.net using the AspAlliance site.... it does point
out that there is a problem - other translaters do not


Public Sub Load(FileName As String)
Dim l As LineToDraw

Try

Me.Clear(True)

Dim sr As New StreamReader(FileName)

Dim line As String
' PLEASE LOOK RIGHT BELOW HERE
'The errror message associated with the line below is - 'Is' requires
operands that have reference types, but this operand has the value type
'Boolean'
While Not ((line <<= sr.ReadLine()) Is Nothing) 'ToDo: Unsupported
feature: assignment within expression. "=" changed to "<="

l = New LineToDraw()

Dim linesplit As String() = line.Split(Delimiter.ToCharArray())

l.StartX = Integer.Parse(linesplit(0).ToString())
l.StartY = Integer.Parse(linesplit(1).ToString())
l.EndX = Integer.Parse(linesplit(2).ToString())
l.EndY = Integer.Parse(linesplit(3).ToString())
Points.Add(l)
End While

sr.Close()

Catch
End Try
End Sub 'Load
 
T

Tom Shelton

Rob said:
Any idease on how to fix ?
Public Sub Load(FileName As String)
Dim l As LineToDraw

Try

Me.Clear(True)

Dim sr As New StreamReader(FileName)
Dim line As String = sr.ReadLine()
While Not line Is Nothing

l = New LineToDraw()

Dim linesplit As String() = line.Split(Delimiter.ToCharArray())

l.StartX = Integer.Parse(linesplit(0).ToString())
l.StartY = Integer.Parse(linesplit(1).ToString())
l.EndX = Integer.Parse(linesplit(2).ToString())
l.EndY = Integer.Parse(linesplit(3).ToString())
Points.Add(l)

line = sr.ReadLine ()
 
G

Guest

The converter you used didn't convert the catch correctly. It should be:
Catch e1 As Exception
Throw

As a side note, our converter (Instant VB) also provides the 'todo' comment
for assignments within expressions. But you're right - most on-line
converters ignore or even delete code when encountering syntax that isn't
converted.

--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C# to C++ converter & VB to C++ converter
Instant J#: VB to J# converter
 

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

Top