GE Intelligent Platforms GEIP e-Forum


NOTICE: This forum is for users to exchange information about GE Intelligent Platforms products. While it is moderated by GE, each post may not be explicitly answered by GE Intelligent Platforms employees. If your case needs an immediate response, please call 1-800-433-2682.

Go Back   GE Intelligent Platforms e-Forum > Industrial Software > HMI/SCADA - iFIX

HMI/SCADA - iFIX Our second generation of HMI/SCADA technology. More secure, more powerful and more versatile than any other offering. Forum also includes WebSpace discussions.

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 03-01-2012, 09:40 AM
irm12464 irm12464 is offline
New Member
 
Join Date: Feb 2008
Posts: 4
irm12464 is on a distinguished road
iFIX Charting VBA Add/Delete pen

I am producing a Trend screen that the user can select his pens by a check box.

The adding is working fine but then when i unselect the check box how do i know which pen to delete.

Here is part iof the code i am using

Private Sub CheckBox1_Click()
Dim objpen As Object
Dim StrSource As String
Dim IntDelete As Integer

StrSource = "hist.Fix.CLF_A1_DT18.F_CV"

If GSKA_POC.CheckBox1.Value Then
For iCnt = 0 To X
On Error Resume Next
Chart4.addpen StrSource, 2
Next iCnt
Chart4.RefreshChartData
Else

Chart4.Deletepen ????????
Chart4.RefreshChartData
End If


End Sub


Any help would be appreciated
Reply With Quote
  #2  
Old 03-01-2012, 10:57 PM
granvil granvil is offline
Principal Member
 
Join Date: Feb 2007
Location: Auckland, New Zealand
Posts: 682
granvil is on a distinguished road
Private Sub CheckBox1_Click()
Dim objChart As Object
Dim objPen As Object
Dim i As Integer
Dim strSource As String

strSource = "hist.Fix.CLF_A1_DT18.F_CV"

Set objChart = FindLocalObject(Me, "Chart")

If CheckBox1.Value = True Then
objChart.AddPen strSource, True
Else

For i = 1 To objChart.Pens.Count

Set objPen = objChart.Pens.Item(i)

If LCase(objPen.Source) = LCase(strSource) Then
objChart.DeletePen (i)
End If

Next


End If

objChart.RefreshChartData
End Sub

Note: The "hist." becomes "Hist." when added to the chart so it is necessary to match Case when comparing text.

Last edited by granvil; 03-01-2012 at 11:00 PM.
Reply With Quote
  #3  
Old 03-06-2012, 01:44 PM
irm12464 irm12464 is offline
New Member
 
Join Date: Feb 2008
Posts: 4
irm12464 is on a distinguished road
Granvil

Thanks, I have added Three checkboxes and can select Three different Sources OK and if i deselect in the same order I select then they are removed OK.

If i uncheck the box in a different order I get an error at

Set objPen = objChart.Pens.Item(i)
Reply With Quote
  #4  
Old 03-06-2012, 08:01 PM
granvil granvil is offline
Principal Member
 
Join Date: Feb 2007
Location: Auckland, New Zealand
Posts: 682
granvil is on a distinguished road
I suspect a typo.
please post the code behind the checkboxes.
Reply With Quote
  #5  
Old 03-06-2012, 08:13 PM
granvil granvil is offline
Principal Member
 
Join Date: Feb 2007
Location: Auckland, New Zealand
Posts: 682
granvil is on a distinguished road
No typo - just bad code

Quote:
Originally Posted by granvil View Post
I suspect a typo.
please post the code behind the checkboxes.
Private Sub CheckBox1_Click()
Dim objChart As Object
Dim objPen As Object
Dim i As Integer
Dim strSource As String

strSource = "hist.Fix.CLF_A1_DT18.F_CV"

Set objChart = FindLocalObject(Me, "Chart")

If CheckBox1.Value = True Then
objChart.AddPen strSource, True
Else

For i = 1 To objChart.Pens.Count

Set objPen = objChart.Pens.Item(i)

If LCase(objPen.Source) = LCase(strSource) Then
objChart.DeletePen (i)
Exit For
End If

Next


End If

objChart.RefreshChartData
End Sub

It was continuing to search the list of Pens after having deleted one of them. So now when we delete the Pen we quit the For Loop.
Reply With Quote
  #6  
Old 03-07-2012, 10:02 AM
jstein's Avatar
jstein jstein is offline
Keeper, Arcane Knowledge
 
Join Date: Jan 2003
Location: Foxboro, MA
Posts: 2,192
jstein is on a distinguished road
see also the code behind the "quick trend" picture.
__________________
"Whatever you do, dont ask me about Proficy Common Licensing" - me
Reply With Quote
  #7  
Old 03-07-2012, 02:02 PM
irm12464 irm12464 is offline
New Member
 
Join Date: Feb 2008
Posts: 4
irm12464 is on a distinguished road
Thanks, I was getting there last night but it was late.

Your support/advise is much appreciated
Reply With Quote
Reply

Tags
add , chart , delete , pen , vba

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 08:53 PM.


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.

e-Forum Legal Notice





Contact Us     |     Privacy Policy     |     Terms & Conditions     2010 General Electric Company