473,320 Members | 1,958 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,320 software developers and data experts.

convert vb.net to csharp

Dear Group,
I have the following code for vb.net

***
Dim objFaxServer As New FAXCOMEXLib.FaxServer

Dim collFaxIncomingJobs As FaxIncomingJobs

Dim objFaxIncomingJob As FaxIncomingJob

'Error handling

On Error GoTo Error_Handler

'Connect to the fax server

objFaxServer.Connect("")

'Get the collection of jobs in the incoming queue

collFaxIncomingJobs = objFaxServer.Folders.IncomingQueue.GetJobs()

'Display the number of jobs in the collection

MsgBox("There are " & collFaxIncomingJobs.Count & " jobs in the incoming
queue.")

Dim n As Long

'Get the job

n = InputBox("Input the item number for which you want information.")

objFaxIncomingJob = collFaxIncomingJobs.Item(n)

Exit Sub

Error_Handler:

'Implement error handling at the end of your subroutine. This implementation
is for demonstration purposes

MsgBox("Error number: " & Hex(Err.Number) & ", " & Err.Description)

***

here is what I come up with in CSharp

FAXCOMEXLib.FaxServer objFaxServer = new FAXCOMEXLib.FaxServer();

FaxIncomingJobs colIJs = objFaxServer.Folders.IncomingQueue.GetJobs();

objFaxServer.Connect("");

for (int i=1;i< colIJs.Count ; i++)

{

//csharp won't compile this line saying no definition for Item

FaxIncomingJob oIJ = colIJs.Item(i);

//do some process

}

What I want to do is loop through Jobs and record them to the database, it
seems like my conversion is not correct

Please help

TIA

L.Peter
Nov 15 '05 #1
4 5764
I'll give it a try, my VB knowledge is somewhat lacking.
Remember, VB uses () for arrays, and C# []

FAXCOMEXLib.FaxServer objFaxServer = new FAXCOMEXLib.FaxServer();

FaxIncomingJobs collFaxIncomingJobs;

FaxIncomingJob objFaxIncomingJob;

"On Error GoTo Error_Handler" ??? is this valid VB code?
maybe a try catch statement

try
{
objFaxServer.Connect("");

collFaxIncomingJobs = objFaxServer.Folders.IncomingQueue.GetJobs();

MsgBox("There are " + collFaxIncomingJobs.Count + " jobs in the incoming
queue.");

long n;

n = InputBox("Input the item number for which you want information.");

objFaxIncomingJob = collFaxIncomingJobs.Item[n];

return; // the return isn't necessary as the catch block is ignored if
the try block is successfull
}
catch(Exception ex)
{
MsgBox("Error: " + ex.Message); // no error number
}

--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
Nov 15 '05 #2
Hi Morten Wennevik,
Thank you for your help.
Csharp still choked at the line

objFaxIncomingJob = collFaxIncomingJobs.Item[n];

It's weird as I can compile the code in VB.net but not in c#, i just cannot
find item from FaxIncomingJobs collection.
i include the link here if you need more info
http://msdn.microsoft.com/library/de...nta_n_5ga5.asp

Regards

L.Peter
Nov 15 '05 #3
in C# the Item is the indexer, so use this:
objFaxIncomingJob = collFaxIncomingJobs[n];

--
Nos vemos.
Guillermo
--------------
P.S.
Si te parece últil mi sitio:
http://www.elguille.info/lonuevo/lo_nuevo0312.htm#dic30
--------------
Microsoft VB MVP desde 1997
Te invito a mi sitio dedicado al VB y más...
http://www.elguille.info/
http://www.mundoprogramacion.com/
(puede que el correo usado sea anti-spam)
"L.Peter" <no@spam.local> wrote in message
news:eh**************@TK2MSFTNGP09.phx.gbl...
Hi Morten Wennevik,
Thank you for your help.
Csharp still choked at the line

objFaxIncomingJob = collFaxIncomingJobs.Item[n];

It's weird as I can compile the code in VB.net but not in c#, i just cannot
find item from FaxIncomingJobs collection.
i include the link here if you need more info
http://msdn.microsoft.com/library/de...nta_n_5ga5.asp
Regards

L.Peter

Nov 15 '05 #4
Hi Guillermo,
your code works. You make my pc listen :-)
Thanks a lot

Regards

L.Peter

"Guillermo 'guille'" <gu****@en.elguille.info> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
in C# the Item is the indexer, so use this:
objFaxIncomingJob = collFaxIncomingJobs[n];

--
Nos vemos.
Guillermo
--------------
P.S.
Si te parece últil mi sitio:
http://www.elguille.info/lonuevo/lo_nuevo0312.htm#dic30
--------------
Microsoft VB MVP desde 1997
Te invito a mi sitio dedicado al VB y más...
http://www.elguille.info/
http://www.mundoprogramacion.com/
(puede que el correo usado sea anti-spam)
"L.Peter" <no@spam.local> wrote in message
news:eh**************@TK2MSFTNGP09.phx.gbl...
Hi Morten Wennevik,
Thank you for your help.
Csharp still choked at the line

objFaxIncomingJob = collFaxIncomingJobs.Item[n];

It's weird as I can compile the code in VB.net but not in c#, i just cannot find item from FaxIncomingJobs collection.
i include the link here if you need more info

http://msdn.microsoft.com/library/de...nta_n_5ga5.asp

Regards

L.Peter


Nov 15 '05 #5

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

Similar topics

11
by: Altramagnus | last post by:
I have a complicated Region object, which I need to draw the outline, but not fill How can I convert the Region object to GraphicsPath object? or How can I draw the outline of the Region object?
3
by: hunterb | last post by:
I have a file which has no BOM and contains mostly single byte chars. There are numerous double byte chars (Japanese) which appear throughout. I need to take the resulting Unicode and store it in a...
7
by: cs_hart | last post by:
I have an application in Java that I would like to port to c++ to integrate with existing c++ app. is anyone aware of any tools to help? I found microsft has a java->csharp convert, but the java...
2
by: Christopher Beltran | last post by:
I am currently trying to replace certain strings, not single characters, with other strings inside a word document which is then sent to a browser as a binary file. Right now, I read in the word...
1
by: Tamir Khason | last post by:
Somebody knows how to convert Bounds to Point ??? Thnx
2
by: Aaron Prohaska | last post by:
Can anyone tell me how I can convert the following code to csharp? I'm having problems with this because it seems as though KeyChar.IsDigit doesn't exist in csharp. ...
3
by: Mike | last post by:
Hi, Does anyone know of reliable programs that convert C# to Java and viceversa? Thanks Mike
5
by: moondaddy | last post by:
How do I get the string representation of an int? for example int var1 = 2; string var2 = var1.ToString; I'm wanting var2 to be "2" I get the compile error: Error 1 Cannot convert...
4
by: kvicky | last post by:
I have multiline textbox and I am trying to do a search functionality based on the input entered in this Textbox. I am able to convert into a string array if the search components are separated by...
18
by: MrVS | last post by:
Hi, I have a C++ CLR class method that takes System::Byte *b as parameter argument. I want the CSharp caller pass a byte * to this function. But in the CSharp prorgram, I only managed to create a...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.