# Graphics in Flex pendant

**URL:** <https://tech-community.robotics.abb.com/t/graphics-in-flex-pendant/367>\
**Category:** Developer Tools\
**Created:** [May 18, 2005, 9:03am UTC](https://tech-community.robotics.abb.com/t/graphics-in-flex-pendant/367 "2005-05-18T09:03:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![oscar\_f](https://avatars.discourse-cdn.com/v4/letter/o/dbc845/32.png) [@oscar\_f](https://tech-community.robotics.abb.com/u/oscar_f)\
**Post date:** [May 18, 2005, 9:03am UTC](https://tech-community.robotics.abb.com/t/graphics-in-flex-pendant/367/1 "2005-05-18T09:03:55Z")

</div>

Hello,

I’m testing the RAB in order to make some drawings on the FP for our next Open House

this is a simple example.

When you click button1 , it draws a line.

It works fine in the VIRC5, but when I deploy it to the robot I get an exception on button1\_Click 😠

This is the code

Private Sub Button1\_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim myGraphics As Graphics

Dim myPen As Pen

myPen = New Pen(Color.Red)

myGraphics = Me.PictureBox1.CreateGraphics()

myGraphics.DrawLine(myPen, 10, 10, 50, 50)

End Sub

Is the system.drwing.graphics supported by the FP?Is there a different way to work?

Here there is also the complete project:

[TpsViewDrawTest.zip](http://forums.robotstudio.com/webwiz/TpsViewDrawTest.zip)

Thanks

Oscar

---

<div class="post-metadata">

**Author:** ![RussD](https://avatars.discourse-cdn.com/v4/letter/r/dec6dc/32.png) [@RussD](https://tech-community.robotics.abb.com/u/RussD)\
**Post date:** [May 18, 2005, 2:56pm UTC](https://tech-community.robotics.abb.com/t/graphics-in-flex-pendant/367/2 "2005-05-18T14:56:01Z")

</div>

What is the message associated with the exception?

You may want to put that code in a Try…Catch block to handle the exception and recover more gracefully. You can put the exception into a Message Box and try to format it better by incrementing a value representing the current line of code. You can then use this number as the title to an error handling dialog. For example:

Dim shLineNum as short

Try

shLineNum = 157 'add your current line number in code here

rd = ctrl.Rapid.GetRapidData(T\_ROB1, MData, “m\_GN\_String2”)

shLineNum += 1 'increment the line counter for each line of code

If rd Is Nothing Then

shLineNum += 1

strWarning = “Rapid Access Error reading variable m\_GN\_String2”

shLineNum += 1

Throw New Exception(strWarning)

shLineNum += 1

Else

shLineNum += 1

'do work here

End If

Catch ex As Exception

'pass the line number as the title of the dialog

'it should indicate the line where the exception was thrown

GTPUMessageBox.Show(Me, \_

Nothing, \_

ex.Message, shLineNum.ToString(), \_

System.Windows.Forms.MessageBoxIcon.Asterisk, \_

System.Windows.Forms.MessageBoxButtons.OKCancel)

Finally

If Not rd Is Nothing Then

rd.Dispose()

rd = Nothing

End If

End Try

---

<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:** [October 26, 2005, 2:08am UTC](https://tech-community.robotics.abb.com/t/graphics-in-flex-pendant/367/3 "2005-10-26T02:08:16Z")

</div>

I have the same problem as oscar\_f.

Can any body explain this?

Thank you in adveance.
