Home All Groups Group Topic Archive Search About

Need help with Conversion from C# to VB.net

Author
24 May 2006 5:22 PM
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

Author
24 May 2006 5:28 PM
Tom Shelton
Rob wrote:
> 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 ()
Show quoteHide quote
>       End While
>
>       sr.Close()
>
>    Catch
>    End Try
> End Sub 'Load

--
Tom Shelton [MVP]
Author
24 May 2006 6:10 PM
Rob
Thank you so much !


Show quoteHide quote
"Tom Shelton" <t**@mtogden.com> wrote in message
news:1148491738.662380.123410@y43g2000cwc.googlegroups.com...
>
> Rob wrote:
>> 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 ()
>>       End While
>>
>>       sr.Close()
>>
>>    Catch
>>    End Try
>> End Sub 'Load
>
> --
> Tom Shelton [MVP]
>
Author
24 May 2006 10:04 PM
David Anton
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



Show quoteHide quote
"Rob" wrote:

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