473,503 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need help with Conversion from C# to VB.net

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
May 24 '06 #1
3 1619

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]

May 24 '06 #2
Rob
Thank you so much !
"Tom Shelton" <to*@mtogden.com> wrote in message
news:11**********************@y43g2000cwc.googlegr oups.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]

May 24 '06 #3
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

"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

May 24 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
6467
by: Nikhil Patel | last post by:
Hi all, I am a VB6 programmer and learning C#. I am currently reading a chapter on types. I have question regarding enums. Why do we need to convert enum members to the value that they represent?...
48
3181
by: Chad Z. Hower aka Kudzu | last post by:
A few of you may recognize me from the recent posts I have made about Indy <http://www.indyproject.org/indy.html> Those of you coming to .net from the Delphi world know truly how unique and...
8
2598
by: John Bowman | last post by:
Hello, Does anyone have a good/reliable approach to implementing an IsNumeric() method that accepts a string that may represent a numerical value (eg. such as some text retrieved from an XML...
3
1880
by: Francesc | last post by:
Hi, I'm new at this newsgroup and I want do ask some questions and opinions about this subject. I'm developing an application focused in a very specific task: clean and labelling text documents...
4
1678
by: Gregory Edigaroff | last post by:
Hello, Everybody! Ok, I urgently need the solution for a following task in C++. This is the task from programmers contest, so I believe somebody have a solution for it. I need either a full...
8
1637
by: SpreadTooThin | last post by:
Basically I think the problem is in converting from a 32 bit integer to a 16 bit integer. I have two arrays: import array a = array.array('L', ) b = array.array('H', ) b = a
31
3100
by: Martin Jørgensen | last post by:
Hi, I've had a introductory C++ course in the spring and haven't programmed in C++ for a couple of months now (but I have been programmed in C since january). So I decided to do my conversion...
1
3641
by: Dancefire | last post by:
Hi, everyone, I'm trying to use std::codecvt<to do the encoding conversion. I am using following code for encoding conversion between wchar_t string and char string(MBCS). I am not sure am I...
15
2152
by: Jess | last post by:
Hello, Sometimes declarations are all what we need when we define/declare classes (or functions?), but sometimes we need definitions. I learned that if we define a class (B) that has an object...
5
2101
by: Ivan Velev | last post by:
Hello, Minimal example below - it gives me different output if I comment / uncomment the extra time.mktime call - note that this call is not related in any way to main logic flow. When...
0
7192
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7064
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7261
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6974
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7445
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5559
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3158
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3147
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
721
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.