473,669 Members | 2,449 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help needed for VB --> C# translation

Hi,
I've been translating some API's from VB to C# for a couple of days now.
Only I'm a real newbie to both languages, but I managed to do most of it
except the next statements, so if anyone knows what the counterpart in C# is
of those VB statements I would appreciate :

Public Function (ok, public I know but what is a Function in C# ?)

Public Enum

Friend Property (need to know both Friend and Property)

Dim wRecordset As DAO.Recordset (I need to know the DAO.Recordset part)

On Error GoTo errHandler

Private mCol as Collection (C# counterpart of Collection ??, thought i could
use object here)

Exit Function

Set NewEnum = mCol.[_NewEnum]

And is there in C# something like modules (classes) ???

Thanx, please respond if u knw any of these...

Nov 16 '05 #1
9 1504
On Mon, 21 Jun 2004 15:06:00 +0200, tiger79 <po**@freemail. nl> wrote:
Hi,
I've been translating some API's from VB to C# for a couple of days now.
Only I'm a real newbie to both languages, but I managed to do most of it
except the next statements, so if anyone knows what the counterpart in C# is
of those VB statements I would appreciate :

Public Function (ok, public I know but what is a Function in C# ?)
Sub and Function is the same in C#. A Sub is a method returning 'void', where a Function can return anything else.

public void DoSomething() // Public Sub DoSomething
{
}

public string DoSomething() // Public Function DoSomething
{
}


Public Enum

public enum
Friend Property (need to know both Friend and Property)

Someone else could explain this much better than me. I don't think there is a Friend in C#
Dim wRecordset As DAO.Recordset (I need to know the DAO.Recordset part)

DAO.Recordset wRecordset;
DAO is a namespace or class where Recordset is defined
On Error GoTo errHandler

try
{
}
catch
{
}
Private mCol as Collection (C# counterpart of Collection ??, thought i could
use object here)

Not sure if there is a C# counterpart of Collection
Exit Function

return;
Set NewEnum = mCol.[_NewEnum]

Not sure
And is there in C# something like modules (classes) ???

There is a Module class if that is what you mean. It's in .Net Framework and doesn't belong to any particular language.
Thanx, please respond if u knw any of these...


--
Happy coding!
Morten Wennevik [C# MVP]
Nov 16 '05 #2
> Public Function (ok, public I know but what is a Function in C# ?)

public int myFunction()
{

}

(where int is the return type, myFunction is the function name)
Public Enum pretty much the same.
public enum myEnum
{
element1,
element2
}
Friend Property (need to know both Friend and Property) internal int myProperty
{
get
{
return someValue;
}
set
{
someVariable = value;
}
}
Dim wRecordset As DAO.Recordset (I need to know the DAO.Recordset part) No such thing. DataTable is probably the closest thing, you'll have to read
up on it I'm afraid as they're quite different.
Private mCol as Collection (C# counterpart of Collection ??, thought i could use object here) Hashtable mCol = new Hashtable();

Don't forget to put a 'using System.Collecti ons' at the top.
Exit Function return
Set NewEnum = mCol.[_NewEnum] IEnumerator newEnum = mCol.GetEnumera tor()
And is there in C# something like modules (classes) ???

public class MyClass
{

}

Nov 16 '05 #3

First of all thanx for the swift answers,
I'd like to point out something regarding this :
Dim wRecordset As DAO.Recordset (I need to know the DAO.Recordset part) No such thing. DataTable is probably the closest thing, you'll have to read
up on it I'm afraid as they're quite different.

I am using a SQL CE 2.0 database now instead than a reald dataset, so is
there code that directly connects to such databases ???
"John Wood" <sp**@isannoyin g.com> wrote in message
news:uk******** ******@TK2MSFTN GP12.phx.gbl...
Public Function (ok, public I know but what is a Function in C# ?)


public int myFunction()
{

}

(where int is the return type, myFunction is the function name)
Public Enum

pretty much the same.
public enum myEnum
{
element1,
element2
}
Friend Property (need to know both Friend and Property)

internal int myProperty
{
get
{
return someValue;
}
set
{
someVariable = value;
}
}
Dim wRecordset As DAO.Recordset (I need to know the DAO.Recordset part)

No such thing. DataTable is probably the closest thing, you'll have to

read up on it I'm afraid as they're quite different.
Private mCol as Collection (C# counterpart of Collection ??, thought i

could
use object here)

Hashtable mCol = new Hashtable();

Don't forget to put a 'using System.Collecti ons' at the top.
Exit Function

return
Set NewEnum = mCol.[_NewEnum]

IEnumerator newEnum = mCol.GetEnumera tor()
And is there in C# something like modules (classes) ???

public class MyClass
{

}

Nov 16 '05 #4

"tiger79" <po**@freemail. nl> wrote in message
news:eS******** ******@TK2MSFTN GP11.phx.gbl...
Hi,
I've been translating some API's from VB to C# for a couple of days now.
Only I'm a real newbie to both languages, but I managed to do most of it
except the next statements, so if anyone knows what the counterpart in C# is of those VB statements I would appreciate :

Public Function (ok, public I know but what is a Function in C# ?)

Public Enum

Friend Property (need to know both Friend and Property)

Dim wRecordset As DAO.Recordset (I need to know the DAO.Recordset part)

On Error GoTo errHandler

Private mCol as Collection (C# counterpart of Collection ??, thought i could use object here)

Exit Function

Set NewEnum = mCol.[_NewEnum]

And is there in C# something like modules (classes) ???

Thanx, please respond if u knw any of these...

I don't want to pour cold water on your aspirations, but just telling you
(roughly) equivalent keywords isn't going to help you much, unless you know
something about the .NET Framework and the differences between .NET
languages and pre-.NET Visual Basic.

I could tell you that the equivalent of Function Procedure (or Subprocedure,
for that matter) is either value returning method or void method, but that's
not much help if you don't know that the word method does not appear in a C#
method definition or call.

Another example: On Error GoTo ~== try, catch, finally, but the translation
requires that you understand a completely new and different error handling
mechanism.

I believe you need some basic training in both .NET and C# to be successful.
There are lots of places on the web where you can start:

http://www.csharp-station.com/
http://support.microsoft.com/default.aspx?pr=vcc
http://support.microsoft.com/default...&product=vbNET
http://support.microsoft.com/default...b;en-us;309617
--
Peter [MVP Visual Developer]
Jack of all trades, master of none.
Nov 16 '05 #5

Thanx, but maybe I've exageratted by saying im a real newbie... I've been
using C# for 2 months now to develop Compact Framework softwar (on a
pocketpc)...
Before that I've been using C++ and Java, so about methods and stuff I know
the basics...
And when I rougly know what the translation is it goes unsaid that first I
try to get out of MSDN as much as I can about the new statements or
argument....
"Peter van der Goes" <p_**********@t oadstool.u> wrote in message
news:u%******** ********@TK2MSF TNGP11.phx.gbl. ..

"tiger79" <po**@freemail. nl> wrote in message
news:eS******** ******@TK2MSFTN GP11.phx.gbl...
Hi,
I've been translating some API's from VB to C# for a couple of days now.
Only I'm a real newbie to both languages, but I managed to do most of it
except the next statements, so if anyone knows what the counterpart in
C# is
of those VB statements I would appreciate :

Public Function (ok, public I know but what is a Function in C# ?)

Public Enum

Friend Property (need to know both Friend and Property)

Dim wRecordset As DAO.Recordset (I need to know the DAO.Recordset part)

On Error GoTo errHandler

Private mCol as Collection (C# counterpart of Collection ??, thought i could
use object here)

Exit Function

Set NewEnum = mCol.[_NewEnum]

And is there in C# something like modules (classes) ???

Thanx, please respond if u knw any of these...

I don't want to pour cold water on your aspirations, but just telling you
(roughly) equivalent keywords isn't going to help you much, unless you

know something about the .NET Framework and the differences between .NET
languages and pre-.NET Visual Basic.

I could tell you that the equivalent of Function Procedure (or Subprocedure, for that matter) is either value returning method or void method, but that's not much help if you don't know that the word method does not appear in a C# method definition or call.

Another example: On Error GoTo ~== try, catch, finally, but the translation requires that you understand a completely new and different error handling
mechanism.

I believe you need some basic training in both .NET and C# to be successful. There are lots of places on the web where you can start:

http://www.csharp-station.com/
http://support.microsoft.com/default.aspx?pr=vcc
http://support.microsoft.com/default...&product=vbNET http://support.microsoft.com/default...b;en-us;309617
--
Peter [MVP Visual Developer]
Jack of all trades, master of none.

Nov 16 '05 #6
Hmmm... sorry I don't know that much about SQL for CE. But all .net
implementations , on pocketpc or whatever, use ADO.Net. Have a look at the
SqlClient namespace for more info on how you can use DataTables with SQL.

"tiger79" <po**@freemail. nl> wrote in message
news:eV******** ******@TK2MSFTN GP12.phx.gbl...

First of all thanx for the swift answers,
I'd like to point out something regarding this :
Dim wRecordset As DAO.Recordset (I need to know the DAO.Recordset part) No such thing. DataTable is probably the closest thing, you'll have to

read up on it I'm afraid as they're quite different.

I am using a SQL CE 2.0 database now instead than a reald dataset, so is
there code that directly connects to such databases ???
"John Wood" <sp**@isannoyin g.com> wrote in message
news:uk******** ******@TK2MSFTN GP12.phx.gbl...
Public Function (ok, public I know but what is a Function in C# ?)


public int myFunction()
{

}

(where int is the return type, myFunction is the function name)
Public Enum

pretty much the same.
public enum myEnum
{
element1,
element2
}
Friend Property (need to know both Friend and Property)

internal int myProperty
{
get
{
return someValue;
}
set
{
someVariable = value;
}
}
Dim wRecordset As DAO.Recordset (I need to know the DAO.Recordset
part) No such thing. DataTable is probably the closest thing, you'll have to

read
up on it I'm afraid as they're quite different.
Private mCol as Collection (C# counterpart of Collection ??, thought i

could
use object here)

Hashtable mCol = new Hashtable();

Don't forget to put a 'using System.Collecti ons' at the top.
Exit Function

return
Set NewEnum = mCol.[_NewEnum]

IEnumerator newEnum = mCol.GetEnumera tor()
And is there in C# something like modules (classes) ???

public class MyClass
{

}


Nov 16 '05 #7
Download a free VB.NET to C# converter (for instance:
www.instantcsharp.com has a free demo). Doing this stuff line by
line, case by case, is nuts.
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Nov 16 '05 #8
Hi PseudoBill,

I tried the demo version of the instantcsharp doodad, but within five minutees I experienced severe doubt as to its use. Note that it can't cope with Vb.Net named arguments (not that many use them, but some -me! - do). The converter maps my arg1:=whatever to arg:== and expresses the view that much of the transliterated code contains 'invalid expression terms', the nerve!

The rest may be great, and I may have been unlucky in my experience, but I'll stick with the Reflector for now.

Regards SteveW
--
toujours gai, wotthehell wotthehell
"PseudoBill " wrote:
Download a free VB.NET to C# converter (for instance:
www.instantcsharp.com has a free demo). Doing this stuff line by
line, case by case, is nuts.
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com

Nov 16 '05 #9
> Steve Wilsonwrote:
Hi PseudoBill,

I tried the demo version of the instantcsharp doodad, but within five minutees I experienced severe doubt as to its use. Note that it
can't cope with Vb.Net named arguments (not that many use them, but
some -me! - do). The converter maps my arg1:=whatever to arg:== and
expresses the view that much of the transliterated code contains
'invalid expression terms', the nerve!
The rest may be great, and I may have been unlucky in my experience, but I'll stick with the Reflector for now.
Regards SteveW
--
toujours gai, wotthehell wotthehell
"PseudoBill " wrote:

Download a free VB.NET to C# converter (for instance:
www.instantcsharp.com has a free demo). Doing this stuff line by
line, case by case, is nuts.
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
[/quote:9ff0de7dc f]

Hi Steve:
Instant C# does convert calls to methods using named parameters. One
of our samples shows this (Samples/Unique VB Features/Named Arguments
from the context menu). Obviously, there is some case or format that
isn't working to your satisfaction - could you submit an example that
doesn't work for you?

Either reply here or contact me directly at
da**@tangibleso ftwaresolutions .com. We are very interested in our
users' input (even those who decide that our free Demo Edition is
sufficient for their needs - it all contributes to a better product).
If we can address a concern, we will typically have a new build
available to you within a few hours.

Nov 16 '05 #10

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

Similar topics

6
2959
by: Sims | last post by:
Hi, Given a string $txt and an array of strings $txt_array what would be the best/fastest way to search in _insensitive_ case if $txt is in $text_array and, if it is, where is it? Because I want to use the array with an ID Something like,
6
2667
by: Jack Smith | last post by:
Help needed on this question. Any help is appreciated. Thanks in advance. Given a binary string (i.e. a finite sequence of 0's and 1's) we choose any two digit substring 01 and replace it by a string of the form 100...0 using an arbitrary (but finite) number of zeros. Prove by induction that this transformation can not be performed infinitely many times, i.e. this sequence of transformations must terminate for any input string.
1
1974
by: worzel | last post by:
Hi All, I am looking for a reg ex that will match email addresses withing <a href=mailto blah > links. Actually, I already crafted my own, but with a slight problem: <a href="mailto:fred@blah.com"> emal me</a> woud be matched as expected, but so will:
2
1484
by: Willie | last post by:
I try to setup SQL Server to work with .NET Framework Anyone here willing to help? Step By Step Help Needed. Thanks
14
2176
by: tbird2340 | last post by:
I want to write an if / then statement and have tried using this: var MyVarMailto; if (Request.Form("LoanRequest") == "Under $250,000") { if (Request.Form("Organization") == "1") { MyVarMailto = "emailA@address.com"; } } else if (Request.Form("LoanRequest") == "Over $250,000") { if (Request.Form("Organization") == "1") {
1
1736
by: BHPexpert | last post by:
Regular Expression help needed -------------------------------------------------------------------------------- I want to extract all text that is contained inside the brackets after the word INDIRECT. There must be at least one pair of parentheses, they may be multiple pairs for exampple, this string '=IF($B$9="Off",0,INDIRECT(ADDRESS(1(8),COLUMNS($A$41:C41),,,$B$9 )),()aaaa' has four bracket pairings until the initial "(" is...
1
1267
by: Brian Gallagher | last post by:
I have an aspnet application which I only want part of to be avaliable between the hours of 9am and 5:30pm but I dont know where to start. Help needed!
0
2579
by: Christopher | last post by:
Urgent Help Needed: The EPVH-1.1 Visual Hull Library. Dear All, I am a student doing research in computer vision. The EPVH-1.1 Visual Hull Library will really help a lot in my research. I did have this library before but I didn't keep my copy of this library because I always thought I could download it again form internet. However, the author of this library closed the download
1
2611
by: Joel Fireman | last post by:
Help Needed: Upgrade Fedora 4 / Apache 2 to PHP 5.2.x from 5.0.4 I've been testing Joomla as a content manager for the County offices, and it looks pretty good. Unfortunately, I decided to upgrade it from the 1.0.13 version to 1.5 as we get ready to go live with the web site... and the update installation gives an error in XML processing, which seems (from what I've been able to dredge up in forum discussions) to stem from a known bug in...
5
1425
by: oasis | last post by:
HELP NEEDED : I have developed a testing system thats generates question paper. i want to display this paper to 20 different users in a Server/Client architecture. is there any built-in function in oracle that supports this kind of Situstion or how can i distungish between the different computer(IPS) in oracle .
0
8465
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
8383
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
8894
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8803
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
7407
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
5682
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4206
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...
0
4384
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2792
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

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.