Connecting Tech Pros Worldwide Help | Site Map

convert

Newbie
 
Join Date: Nov 2008
Location: UK
Posts: 25
#1: Oct 8 '09
Hio
I have this code which was written in VB and works in VB, but I have started to convert it to c#. But now I'm stuck. Can somebody help me to finish the conversion please. This is as far as I could get.

Expand|Select|Wrap|Line Numbers
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using System.Threading;
  10. using System.IO;
  11.  
  12. namespace Vision 
  13. {
  14.     public partial class Form1 : Form 
  15.     {
  16.         public Form1() 
  17.         {
  18.         InitializeComponent();
  19.         }
  20.  
  21.         private void Form1_Load(object sender, EventArgs e) 
  22.         {
  23.         picOutputLeft.SizeMode = PictureBoxSizeMode.StretchImage;
  24.         picOutputRight.SizeMode = PictureBoxSizeMode.StretchImage;
  25.         myCamLeft = new ICam();
  26.         myCamRight = new ICam;
  27.         myCamLeft.initCam(picOutputLeft.Handle.ToInt32);
  28.         myCamRight.initCam(picOutputRight.Handle.ToInt32);
  29.         }
  30.  
  31.         public myCamLeft as ICam;
  32.         public myCamRight as ICam;
  33.  
  34.  
  35.         private void btnViewLeftStill_Click(object sender, EventArgs e)
  36.         {
  37.         if (myCamLeft.iRunning = true)
  38.           {
  39.             FrmImage FrmImage = new FrmImage();
  40.             FrmImage.picImage.Image = myCamLeft.copyFrame(picOutputLeft, new RectangleF(0, 0, picOutputLeft.Width, picOutputLeft.Height));
  41.             FrmImage.Show();
  42.           }
  43.         else
  44.           {
  45.             MessageBox.Show("Left Camera Is Not Running!");
  46.           }
  47.         }
  48.  
  49.         public void btnViewRightStill_Click(object sender, EventArgs e)
  50.         {
  51.         if (myCamRight.iRunning = true)
  52.           {
  53.             FrmImage FrmImage = new FrmImage();
  54.             FrmImage.picImage.Image = myCamRight.copyFrame(picOutputRight, new RectangleF(40, 0, picOutputRight.Width, picOutputRight.Height));
  55.             FrmImage.Show();
  56.           }
  57.         else
  58.           {
  59.             MessageBox.Show("Right Camera Is Not Running!");
  60.           }
  61.        }
  62.    }
  63. }
Ta
ssnaik84's Avatar
Member
 
Join Date: Aug 2009
Location: Bengaluru, India
Posts: 119
#2: Oct 8 '09

re: convert


try this online converter

Also, check this article.. it's very good comparison..
tlhintoq's Avatar
Moderator
 
Join Date: Mar 2008
Location: Arizona, USA
Posts: 1,743
#3: Oct 8 '09

re: convert


TIP: When you are writing your question, there is a button on the tool bar that wraps the [code] tags around your copy/pasted code. It helps a bunch. Its the button with a '#' on it. More on tags. They're cool. Check'em out.
Familiar Sight
 
Join Date: Jul 2009
Location: Calgary, Alberta, Canada
Posts: 211
#4: Oct 8 '09

re: convert


Additionally, when you post, can you please describe your problem in a bit more detail? What exactly is wrong with the code, how is it not working, is it throwing exceptions, is it giving unexpected results, and what are those results?

That said, I can spot a problem right away, and definitely a common mistake when going from VB code to C/C++/C# style code (I catch myself on this constantly, so don't feel bad).

Your comparison operators are incorrect. You're actually using an assignment operator. In C/C++/C#, the equivalence comparison operator is == and the assignment operator is =. In VB, they are both =.

So your if statements should be changed from...

Expand|Select|Wrap|Line Numbers
  1. if (something = value)...
... to ...

Expand|Select|Wrap|Line Numbers
  1. if (something == value)...
In your code (lines 37 and 51, specifically), you're assigning values to myCamLeft.iRunning and myCamRight.iRunning, instead of checking their values.
Reply