473,655 Members | 3,114 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(Fi leName);
string line;
while ((line = sr.ReadLine()) != null)
{
l = new LineToDraw();
string[] linesplit = line.Split(Deli miter.ToCharArr ay());
l.StartX = int.Parse(lines plit[0].ToString());
l.StartY = int.Parse(lines plit[1].ToString());
l.EndX = int.Parse(lines plit[2].ToString());
l.EndY = int.Parse(lines plit[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(Fi leName)

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(Deli miter.ToCharArr ay())

l.StartX = Integer.Parse(l inesplit(0).ToS tring())
l.StartY = Integer.Parse(l inesplit(1).ToS tring())
l.EndX = Integer.Parse(l inesplit(2).ToS tring())
l.EndY = Integer.Parse(l inesplit(3).ToS tring())
Points.Add(l)
End While

sr.Close()

Catch
End Try
End Sub 'Load
May 24 '06 #1
3 1631

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(Fi leName) Dim line As String = sr.ReadLine()
While Not line Is Nothing

l = New LineToDraw()

Dim linesplit As String() = line.Split(Deli miter.ToCharArr ay())

l.StartX = Integer.Parse(l inesplit(0).ToS tring())
l.StartY = Integer.Parse(l inesplit(1).ToS tring())
l.EndX = Integer.Parse(l inesplit(2).ToS tring())
l.EndY = Integer.Parse(l inesplit(3).ToS tring())
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.co m> wrote in message
news:11******** **************@ y43g2000cwc.goo glegroups.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(Fi leName)

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

l = New LineToDraw()

Dim linesplit As String() = line.Split(Deli miter.ToCharArr ay())

l.StartX = Integer.Parse(l inesplit(0).ToS tring())
l.StartY = Integer.Parse(l inesplit(1).ToS tring())
l.EndX = Integer.Parse(l inesplit(2).ToS tring())
l.EndY = Integer.Parse(l inesplit(3).ToS tring())
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(Fi leName);
string line;
while ((line = sr.ReadLine()) != null)
{
l = new LineToDraw();
string[] linesplit = line.Split(Deli miter.ToCharArr ay());
l.StartX = int.Parse(lines plit[0].ToString());
l.StartY = int.Parse(lines plit[1].ToString());
l.EndX = int.Parse(lines plit[2].ToString());
l.EndY = int.Parse(lines plit[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(Fi leName)

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(Deli miter.ToCharArr ay())

l.StartX = Integer.Parse(l inesplit(0).ToS tring())
l.StartY = Integer.Parse(l inesplit(1).ToS tring())
l.EndX = Integer.Parse(l inesplit(2).ToS tring())
l.EndY = Integer.Parse(l inesplit(3).ToS tring())
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
6482
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? Thanks in advance... -Nikhil
48
3223
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 "huge" Indy is both as a project, in support, development, and use. But Indy is new to the .net world. Indy is a HUGE library implementing over 120 internet protocols and standards and comes with complete source. Its an open source project, but not...
8
2608
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 file)? Thus if you pass it "1" or "5.12345" it returns true, but "1b3q" it returns false? I know VB has this sort of function, but was wondering how to implement something similar in C#. I suppose I could use the Convert methods and catch any...
3
1892
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 with user-defined structural tags (title, cite, date, paragraph, itemList, ...). It makes the typical pre-processing tasks needed for computational linguistics in order to work with big corporas to use statistical tools. But I'm worried that...
4
1688
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 source code or a simple description of algorithm to solve this task. thank a lot in advance. Unit Conversion A (measurement) unit is here represented by a single word containing only lower-case letters. All
8
1645
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
3130
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 utility in C++, before I forget everything. But it doesn't compile: ------------
1
3656
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 right. The code works, but I'm not familiar with the codecvt, and I don't know my way is the right way to do the job. Could you help me to review the code? This function try to convert a wide string to a MBCS in the loc's charset. I hardcode...
15
2159
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 (a_obj) of a class type (A), then we need to define A as well, but if B has a pointer to A, then we only need to forward declare A. I was told this is because the compiler needs to see the implemenation of A when allocating memory for a_obj. ...
5
2110
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 "problematicStamp = ..." is commented I get gmtStamp: 1130634600.0
0
8380
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8296
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8710
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8598
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7310
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4150
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2721
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1928
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1598
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.