473,803 Members | 3,095 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Converting from VB .NET to C#

Hi,
I have been working using VB .NET and I wanted to convert a code to C#
in VB .Net I use modules so that I can declare variables, STP holders so
that I can replace them easily when I move b/w Dev and Prod like this

Module modAVSVariables
'Arraylist and Array Variables
Friend pathArray As Array
Friend temp_arrAllFile s As Array
Friend getPath As ArrayList = New ArrayList

End Module

............... .....and access them like this in Classes like this:
Public Class HelperClass
Friend Function getPaths() As Boolean
nvc = CType(Configura tionSettings.Ge tConfig("Key"),
NameValueCollec tion)
For Each key As String In nvc.Keys
If nvc(key) = "" Then
_fileError.KeyE rror("Missing Path", "Key", key)
Return False

Else
getPath.Add(nvc (key))

End If

Next
Return True

End Function

Friend function getFiles() as Boolean
temp_arrAllFile s = System.IO.Direc tory.GetFiles(g etPath(0))

End Function

End Class

.... and so on....
whats the equivalent of "module" in C# where i can declare them....

Thanks,
Stephen
Jul 18 '06 #1
5 1406

"stephen" <st********@hot mail.comwrote in message
news:%2******** *******@TK2MSFT NGP05.phx.gbl.. .
Hi,
I have been working using VB .NET and I wanted to convert a code to C#
in VB .Net I use modules so that I can declare variables, STP holders so
that I can replace them easily when I move b/w Dev and Prod like this
Sharpcode has a super Code translator between VB.Net and C#:
http://www.icsharpcode.net/OpenSource/SD/Default.aspx

This will translate it all for you :)
Jul 18 '06 #2
"C# & VB.NET Conversion Pocket Reference" published by O'Reilly is very
useful.
--
<%= Clinton Gallagher
NET csgallagher AT metromilwaukee. com
URL http://www.metromilwaukee.com/clintongallagher/

"Mischa Kroon" <ww*@bloggingab out.netwrote in message
news:ad******** *************** ****@news.chell o.nl...
>
"stephen" <st********@hot mail.comwrote in message
news:%2******** *******@TK2MSFT NGP05.phx.gbl.. .
>Hi,
I have been working using VB .NET and I wanted to convert a code to C#
in VB .Net I use modules so that I can declare variables, STP holders so
that I can replace them easily when I move b/w Dev and Prod like this

Sharpcode has a super Code translator between VB.Net and C#:
http://www.icsharpcode.net/OpenSource/SD/Default.aspx

This will translate it all for you :)


Jul 18 '06 #3

Thanks

"clintonG" <cs*********@RE MOVETHISTEXTmet romilwaukee.com wrote in message
news:%2******** ********@TK2MSF TNGP03.phx.gbl. ..
"C# & VB.NET Conversion Pocket Reference" published by O'Reilly is very
useful.
--
<%= Clinton Gallagher
NET csgallagher AT metromilwaukee. com
URL http://www.metromilwaukee.com/clintongallagher/

"Mischa Kroon" <ww*@bloggingab out.netwrote in message
news:ad******** *************** ****@news.chell o.nl...
>>
"stephen" <st********@hot mail.comwrote in message
news:%2******* ********@TK2MSF TNGP05.phx.gbl. ..
>>Hi,
I have been working using VB .NET and I wanted to convert a code to C#
in VB .Net I use modules so that I can declare variables, STP holders so
that I can replace them easily when I move b/w Dev and Prod like this

Sharpcode has a super Code translator between VB.Net and C#:
http://www.icsharpcode.net/OpenSource/SD/Default.aspx

This will translate it all for you :)



Jul 18 '06 #4
A module is basically a class with only static members.
Our Instant C# VB to C# converter produces the following equivalent C# code:

internal static class modAVSVariables
{
//Arraylist and Array Variables
internal static Array pathArray;
internal static Array temp_arrAllFile s;
internal static ArrayList getPath = new ArrayList();
}

public class HelperClass
{
internal bool getPaths()
{
nvc = (NameValueColle ction)(Configur ationSettings.G etConfig("Key") );
foreach (string key in nvc.Keys)
{
if (nvc(key) == "")
{
_fileError.KeyE rror("Missing Path", "Key", key);
return false;

}
else
modAVSVariables .getPath.Add(nv c(key));

}
return true;

}

internal bool getFiles()
{
modAVSVariables .temp_arrAllFil es =
System.IO.Direc tory.GetFiles(m odAVSVariables. getPath[0]);

//INSTANT C# NOTE: Inserted the following 'return' since all code paths
must return a value in C#:
return false;
}

}

--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C#/VB to C++ converter
C# Code Metrics: Quick metrics for C#
"stephen" wrote:
Hi,
I have been working using VB .NET and I wanted to convert a code to C#
in VB .Net I use modules so that I can declare variables, STP holders so
that I can replace them easily when I move b/w Dev and Prod like this

Module modAVSVariables
'Arraylist and Array Variables
Friend pathArray As Array
Friend temp_arrAllFile s As Array
Friend getPath As ArrayList = New ArrayList

End Module

............... .....and access them like this in Classes like this:
Public Class HelperClass
Friend Function getPaths() As Boolean
nvc = CType(Configura tionSettings.Ge tConfig("Key"),
NameValueCollec tion)
For Each key As String In nvc.Keys
If nvc(key) = "" Then
_fileError.KeyE rror("Missing Path", "Key", key)
Return False

Else
getPath.Add(nvc (key))

End If

Next
Return True

End Function

Friend function getFiles() as Boolean
temp_arrAllFile s = System.IO.Direc tory.GetFiles(g etPath(0))

End Function

End Class

.... and so on....
whats the equivalent of "module" in C# where i can declare them....

Thanks,
Stephen
Jul 18 '06 #5
Someone recommended http://www.tangiblesoftwaresolutions.com

I don't have any personal experience with it.
--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]

"stephen" <st********@hot mail.comwrote in message
news:%2******** *******@TK2MSFT NGP05.phx.gbl.. .
Hi,
I have been working using VB .NET and I wanted to convert a code to C#
in VB .Net I use modules so that I can declare variables, STP holders so
that I can replace them easily when I move b/w Dev and Prod like this

Module modAVSVariables
'Arraylist and Array Variables
Friend pathArray As Array
Friend temp_arrAllFile s As Array
Friend getPath As ArrayList = New ArrayList

End Module

............... ....and access them like this in Classes like this:
Public Class HelperClass
Friend Function getPaths() As Boolean
nvc = CType(Configura tionSettings.Ge tConfig("Key"),
NameValueCollec tion)
For Each key As String In nvc.Keys
If nvc(key) = "" Then
_fileError.KeyE rror("Missing Path", "Key", key)
Return False

Else
getPath.Add(nvc (key))

End If

Next
Return True

End Function

Friend function getFiles() as Boolean
temp_arrAllFile s = System.IO.Direc tory.GetFiles(g etPath(0))

End Function

End Class

... and so on....
whats the equivalent of "module" in C# where i can declare them....

Thanks,
Stephen

Jul 19 '06 #6

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

Similar topics

4
2470
by: mustafa | last post by:
Dear sir , I have built my application in visual basic 6.0 and crystal Report8.5 , Now i migrated my application to VB.net using the upgrade wizard.My visual basic form is upgraded to vb.net but my .dsr file that i created using crystalReport is not migrated , when i try to convert it into .rpt file using add new item in Vb.net Envs it give me the error in the log file saying,
29
3911
by: Armand Karlsen | last post by:
I have a website ( http://www.zen62775.zen.co.uk ) that I made HTML 4.01 Transitional and CSS compliant, and I'm thinking of converting it into XHTML to learn a little about it. Which XHTML variant would you recommend? The w3c HTML validator mentions XHTML 1.0 Transitional, Basic, Strict, and XHTML 1.1. Would I be able to make my existing CSS work in the XHTML page without modification to the .css file?
8
5746
by: prabha | last post by:
Hello Everybody, I have to conert the word doc to multiple html files,according to the templates in the word doc. I had converted the word to xml.Also through Exsl ,had finished the multiple output html files. The problem is while reading through the worddoc paragraph,the special characters are not identified. So in the xml file,it's just storing that as "?".So I couldn't able to retrive the characters in my ouput html files.
5
2527
by: Robert | last post by:
I have a series of web applications (configured as separate applications) on a server. There is a main application at the root and then several virtual directories that are independant applications. I am testing an upgrade of all of the sites and have converted the main root site...although not necessarily fixed any issues. I move on instead and converted one of the virtual roots that is a seperate
3
2428
by: Mary | last post by:
Hi, Does anyone know of any software out there that would convert an application written in VBScript to either VB.NET or C#/C++ quite quickly for me, or will I have to re-write the application myself. Any help much appreciated.
2
6198
by: Map Reader | last post by:
Greetings, I am converting an old VB6 application to use .NET. One of the old controls loads icons from the disk and displays them. However, the transparent color turns to blue somewhere in the process. I narrowed it down to the conversion to IPictureDisp by first loading and saving the icon as a bitmap with no problems; and then repeating the process but adding the step of converting to an IPictureDisp as well. The first operation...
12
3200
by: Frederik Vanderhaeghe | last post by:
Hi, I have a problem converting text to a double. Why doesn't the code work: If Not (txtdocbedrag.Text = "") Then Select Case ddlBedrag.SelectedIndex Case 0 Case 1
7
2713
by: Tor Aadnevik | last post by:
Hi, I have a problem converting values from Single to double. eg. When the Single value 12.19 is converted to double, the result is 12.1899995803833. Anyone know how to avoid this? Regards Totto
4
3197
by: gg9h0st | last post by:
i'm a newbie studying php. i was into array part on tutorial and it says i'll get an array having keys that from member variable's name by converting an object to array. i guessed "i can get public members but not protected, private, static members"
2
5869
by: shenanwei | last post by:
DB2 V8.2 on AIX, type II index is created. I see this from deadlock event monitor. 5) Deadlocked Connection ... Participant no.: 2 Lock wait start time: 09/18/2006 23:04:09.911774 ...... Deadlocked Statement: Type : Dynamic Operation: Execute
0
9703
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
9565
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,...
1
10295
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10069
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
9125
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
6844
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
5501
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
5633
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4275
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.