|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Need help with Conversion from C# to VB.netThe 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 Rob wrote:
> Any idease on how to fix ? Dim line As String = sr.ReadLine()> > Public Sub Load(FileName As String) > Dim l As LineToDraw > > Try > > Me.Clear(True) > > Dim sr As New StreamReader(FileName) > While Not line Is Nothing line = sr.ReadLine ()> > 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) Show quoteHide quote > End While > > sr.Close() > > Catch > End Try > End Sub 'Load -- Tom Shelton [MVP] 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] > 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. -- Show quoteHide quoteDavid 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 "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 > > >
scope of command and garbage collection
How to Use a Screen Saver app within My Application? Object from variable SET ARITHABORT ON: Why (not)? Web Service Question about a conversion project Off Topic - sorry Inline SQL vs stored procs on SQL Server 7 and 2000 Alternate Name How To Associate An Enter Key In TextBox To A Specific Button |
|||||||||||||||||||||||