# What??s wrong with my codes?

**URL:** <https://tech-community.robotics.abb.com/t/what-s-wrong-with-my-codes/1284>\
**Category:** Developer Tools\
**Created:** [June 25, 2007, 8:08am UTC](https://tech-community.robotics.abb.com/t/what-s-wrong-with-my-codes/1284 "2007-06-25T08:08:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![cookie](https://avatars.discourse-cdn.com/v4/letter/c/d26b3c/32.png) [@cookie](https://tech-community.robotics.abb.com/u/cookie)\
**Post date:** [June 25, 2007, 8:08am UTC](https://tech-community.robotics.abb.com/t/what-s-wrong-with-my-codes/1284/1 "2007-06-25T08:08:00Z")

</div>

Hi!

I try to write to a RobTarget object position which is existed, but it doesn’t work, as I run the program, the exception will be thrown. the exception is exactly what I catch in the below"Get value problem"

try  
{  
IRD = rdp1.Value;  
aRobTarget = (RobTarget)IRD;  
aRobTarget.Trans.X = Convert.ToSingle(this.textBoxX.Text);  
aRobTarget.Trans.Y = Convert.ToSingle(this.textBoxY.Text);  
aRobTarget.Trans.Z = Convert.ToSingle(this.textBoxZ.Text);  
rdp1.Value = aRobTarget;  
}  
catch (GeneralException ex)  
{  
throw new ApplicationException(“Get value problem”, ex);  
}

Is there anything wrong with my codes, when I try to modify the target position. Please help me out of this issue. thanks forward.

Best Regards!

---

<div class="post-metadata">

**Author:** ![cookie](https://avatars.discourse-cdn.com/v4/letter/c/d26b3c/32.png) [@cookie](https://tech-community.robotics.abb.com/u/cookie)\
**Post date:** [June 26, 2007, 6:39am UTC](https://tech-community.robotics.abb.com/t/what-s-wrong-with-my-codes/1284/2 "2007-06-26T06:39:16Z")

</div>

I try to modify the codes in the following, refering to RAB manual.But it still doesn’t work. The last line: It seems that I can’t deliver the aRobTarget back to rdp1.value, there always an error when executing"Get value problem". Who knows how to deal with it.

using (Mastership m = Mastership.Request(controller.Rapid))  
{  
RapidData rdp1 = this.controller.Rapid.GetRapidData(“T\_ROB1”, “MainModule”, “p1”);  
RobTarget aRobTarget;  
IRapidData IRD;  
if (rdp1 == null)  
{  
throw new Exception(“Could not find p1!”);  
}  
try  
{  
IRD = rdp1.Value;  
aRobTarget = (RobTarget)IRD;  
aRobTarget.Trans.X = aRobTarget.Trans.X + Convert.ToSingle(this.numericUpDownX.Value);  
aRobTarget.Trans.Y = aRobTarget.Trans.Y + Convert.ToSingle(this.numericUpDownY.Value);  
aRobTarget.Trans.Z = aRobTarget.Trans.Z + Convert.ToSingle(this.numericUpDownZ.Value);  
rdp1.Value = aRobTarget;  
}  
catch (GeneralException ex)  
{  
throw new ApplicationException(“Get value problem”, ex);  
}  
rdp1.Dispose();  
}

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/flex005/user_avatar/tech-community.robotics.abb.com/system/32/6_2.png) [@system](https://tech-community.robotics.abb.com/u/system)\
**Post date:** [July 6, 2007, 11:31am UTC](https://tech-community.robotics.abb.com/t/what-s-wrong-with-my-codes/1284/3 "2007-07-06T11:31:05Z")

</div>

Hi,

I’m not sure about this (I’m just a noob) but, Trans takes float values. You are trying to fill it with Single values. So you might wanna try this:

aRobTarget.Trans.X = aRobTarget.Trans.X + Convert.ToFloat(this.numericUpDownX.Value);

No guarantees though :stuck\_out\_tongue\_winking\_eye:,

Q

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/flex005/user_avatar/tech-community.robotics.abb.com/system/32/6_2.png) [@system](https://tech-community.robotics.abb.com/u/system)\
**Post date:** [July 6, 2007, 11:32am UTC](https://tech-community.robotics.abb.com/t/what-s-wrong-with-my-codes/1284/4 "2007-07-06T11:32:48Z")

</div>

P.S. What exactly is the error msg that you get? Cause just telling us that you get a “general” exception isn’t very helpfull.

Q
