473,396 Members | 1,836 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to translate this C# into VB (generally)

This chunk of code does not translate accurately using the available C# to
VB translator tools.
I am wondering what the "sub within a sub" structure should look like in VB:
starting with the
"public void Fill(DataSet ds)" and "tds = this;" statements. (Sorry, the
indentation did not come across).
Thanks for looking,
Dean Slindee
using System;

using System.Data;

using System.Xml;

namespace Rosters

{

public class TypedDataSet: roster

{

private TypedDataSet tds;
public void Fill(XmlDocument doc)

{

// First populate an untyped DataSet with the xml document

DataSet ds = new DataSet();

byte [] buf = System.Text.ASCIIEncoding.ASCII.GetBytes(doc.Outer Xml);

System.IO.MemoryStream ms = new System.IO.MemoryStream(buf);

ds.ReadXml(ms);

ms.Close();

// Then fill the typed DataSet from the untyped DataSet

Fill(ds);

}
public new void ReadXml(string xmlFile)

{

XmlDocument xmlDoc = new XmlDocument();

try

{

xmlDoc.Load(xmlFile);

this.Fill(xmlDoc);

}

catch (XmlException)

{

// ignore or handle exception here

}
public void Fill(DataSet ds)

{

tds = this;

// Map each row of each table in the untyped DataSet to a

// corresponding item in the strongly typed DataSet

for ( int i = 0; i < ds.Tables.Count; i++ )

{

foreach (DataRow iDr in ds.Tables[i].Rows)

{

DataRow oDr = tds.Tables[i].NewRow();

for ( int j = 0; j < ds.Tables[i].Columns.Count; j++ )

try

{

oDr[j] = iDr[j].ToString();

}

catch (NoNullAllowedException)

{

// ignore for now - just in

// case no such column in DataSet

}

tds.Tables[i].Rows.Add(oDr);

}

}

tds.AcceptChanges();

}

}

}
Nov 20 '05 #1
6 1368
Slindee,

One problem is that you have a missing right brace in the C# code. Try
putting this code back into C#. You will notice the error, then try and
import it again to VB

Regards - OHM#
Dean Slindee wrote:
This chunk of code does not translate accurately using the available
C# to VB translator tools.
I am wondering what the "sub within a sub" structure should look like
in VB: starting with the
"public void Fill(DataSet ds)" and "tds = this;" statements.
(Sorry, the indentation did not come across).
Thanks for looking,
Dean Slindee
using System;

using System.Data;

using System.Xml;

namespace Rosters

{

public class TypedDataSet: roster

{

private TypedDataSet tds;
public void Fill(XmlDocument doc)

{

// First populate an untyped DataSet with the xml document

DataSet ds = new DataSet();

byte [] buf = System.Text.ASCIIEncoding.ASCII.GetBytes(doc.Outer Xml);

System.IO.MemoryStream ms = new System.IO.MemoryStream(buf);

ds.ReadXml(ms);

ms.Close();

// Then fill the typed DataSet from the untyped DataSet

Fill(ds);

}
public new void ReadXml(string xmlFile)

{

XmlDocument xmlDoc = new XmlDocument();

try

{

xmlDoc.Load(xmlFile);

this.Fill(xmlDoc);

}

catch (XmlException)

{

// ignore or handle exception here

}
public void Fill(DataSet ds)

{

tds = this;

// Map each row of each table in the untyped DataSet to a

// corresponding item in the strongly typed DataSet

for ( int i = 0; i < ds.Tables.Count; i++ )

{

foreach (DataRow iDr in ds.Tables[i].Rows)

{

DataRow oDr = tds.Tables[i].NewRow();

for ( int j = 0; j < ds.Tables[i].Columns.Count; j++ )

try

{

oDr[j] = iDr[j].ToString();

}

catch (NoNullAllowedException)

{

// ignore for now - just in

// case no such column in DataSet

}

tds.Tables[i].Rows.Add(oDr);

}

}

tds.AcceptChanges();

}

}

}


Regards - OHM# On**********@BTInternet.com
Nov 20 '05 #2
You are correct about the missing squirrelly bracket (as posted on Code
Project). However, the translation result was the same. The translator (am
I) are thoroughly confused as to how to write a sub inside a sub!

Any ideas?

Thanks,
Dean Slindee
"One Handed Man [ OHM# ]" <On**********@BTInternet.com> wrote in message
news:OV**************@TK2MSFTNGP12.phx.gbl...
Slindee,

One problem is that you have a missing right brace in the C# code. Try
putting this code back into C#. You will notice the error, then try and
import it again to VB

Regards - OHM#
Dean Slindee wrote:
This chunk of code does not translate accurately using the available
C# to VB translator tools.
I am wondering what the "sub within a sub" structure should look like
in VB: starting with the
"public void Fill(DataSet ds)" and "tds = this;" statements.
(Sorry, the indentation did not come across).
Thanks for looking,
Dean Slindee
using System;

using System.Data;

using System.Xml;

namespace Rosters

{

public class TypedDataSet: roster

{

private TypedDataSet tds;
public void Fill(XmlDocument doc)

{

// First populate an untyped DataSet with the xml document

DataSet ds = new DataSet();

byte [] buf = System.Text.ASCIIEncoding.ASCII.GetBytes(doc.Outer Xml);

System.IO.MemoryStream ms = new System.IO.MemoryStream(buf);

ds.ReadXml(ms);

ms.Close();

// Then fill the typed DataSet from the untyped DataSet

Fill(ds);

}
public new void ReadXml(string xmlFile)

{

XmlDocument xmlDoc = new XmlDocument();

try

{

xmlDoc.Load(xmlFile);

this.Fill(xmlDoc);

}

catch (XmlException)

{

// ignore or handle exception here

}
public void Fill(DataSet ds)

{

tds = this;

// Map each row of each table in the untyped DataSet to a

// corresponding item in the strongly typed DataSet

for ( int i = 0; i < ds.Tables.Count; i++ )

{

foreach (DataRow iDr in ds.Tables[i].Rows)

{

DataRow oDr = tds.Tables[i].NewRow();

for ( int j = 0; j < ds.Tables[i].Columns.Count; j++ )

try

{

oDr[j] = iDr[j].ToString();

}

catch (NoNullAllowedException)

{

// ignore for now - just in

// case no such column in DataSet

}

tds.Tables[i].Rows.Add(oDr);

}

}

tds.AcceptChanges();

}

}

}


Regards - OHM# On**********@BTInternet.com

Nov 20 '05 #3
Hi Dean,

What do you mean "Sub inside a sub"?
Do you mean the For statement nested with another for statement?

I think this may be caused by your tool's limitation.
You may take a look at the tool below.
http://authors.aspalliance.com/aldot...translate.aspx
http://csharpconverter.claritycon.com/Default.aspx

If you have any concern on this issue, please post here.

Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 20 '05 #4
check out msdn site for vb.net, they r distributing vb.net resource kit
which comes with a fine C# to vb converter.
"Peter Huang" <v-******@online.microsoft.com> wrote in message
news:T4**************@cpmsftngxa07.phx.gbl...
Hi Dean,

What do you mean "Sub inside a sub"?
Do you mean the For statement nested with another for statement?

I think this may be caused by your tool's limitation.
You may take a look at the tool below.
http://authors.aspalliance.com/aldot...translate.aspx
http://csharpconverter.claritycon.com/Default.aspx

If you have any concern on this issue, please post here.

Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 20 '05 #5
"emailallrise" <em**********@yahoo.com> schrieb
check out msdn site for vb.net, they r distributing vb.net resource kit
which comes with a fine C# to vb converter.


I think Peter knows this.
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #6
* "Armin Zingler" <az*******@freenet.de> scripsit:
"emailallrise" <em**********@yahoo.com> schrieb
check out msdn site for vb.net, they r distributing vb.net resource kit
which comes with a fine C# to vb converter.


I think Peter knows this.


LOL

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #7

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

Similar topics

7
by: Bengt Richter | last post by:
Just thought None as the first argument would be both handy and mnemonic, signifying no translation, but allowing easy expression of deleting characters, e.g., s = s.translate(None,...
1
by: shank | last post by:
I'm sure this is a stretch, but is there some kind of component that I could install to translate from English to Spanish on the fly? I have a lot of equipment features and specifications that I...
4
by: Gadrin77 | last post by:
I have data that looks like <Root> <Main Value="Line1|Line2.|Line3|Line4.|Line5"/> </Root> I'm using Translate(@Value, "|.", ",")
6
by: bobueland | last post by:
The module string has a function called translate. I tried to find the source code for that function. In: C:\Python24\Lib there is one file called string.py I open it and it says
1
by: peterbe | last post by:
This has always worked fine for me. Peter fine Now if I do it with a unicode string: Traceback (most recent call last): File "<stdin>", line 1, in ? File "/usr/lib/python2.4/string.py", line...
8
by: Joergen Bech | last post by:
Suppose I have written a .Net application and - until now - have hardcoded all my text strings. Now, the application needs to be translated into another language. Furthermore, the translation must...
9
bvdet
by: bvdet | last post by:
I have done some more work on a simple class I wrote to calculate a global coordinate in 3D given a local coordinate: ## Basis3D.py Version 1.02 (module macrolib.Basis3D) ## Copyright (c) 2006...
3
by: Kenneth McDonald | last post by:
I have the need to occasionally translate a single word programatically. Would anyone have a Python script that would let me do this using Google (or another) translation service? Thanks, Ken
4
by: kovariadam | last post by:
Hi, Does anybody know why i get this error: SQL0176N The second, third or fourth argument of the TRANSLATE scalar function is incorrect. SQLSTATE=42815 with this query: SELECT...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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,...
0
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
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
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,...

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.