OberonPlace.com Forums  

Go Back   OberonPlace.com Forums > Developer Forums > VBA > CorelDRAW/Corel DESIGNER VBA

Thread Tools Search this Thread Display Modes
Old 27-02-2009, 15:26
Sablesword Sablesword is offline
Junior Member
Join Date: Aug 2006
Posts: 20
Default Checking to see if two variables refer to the same object

In particular, I'm trying to determine if two node variables both refer to the same node. I thought the "is" statement was suppose to do this, but I can't make it work.

 Dim s As Shape
 Dim nr As NodeRange
 Dim nd, nd2 As Node
 Dim boo As Boolean
 Set s = ActiveSelection.Shapes(1)
 If s.Type = cdrCurveShape Then
  Set nr = s.Curve.Selection
 End If
 Set nd = nr.LastNode
 Set nd2 = nr.LastNode
 boo = nd Is nd2
 If boo Then
    (do stuff)
   (do other stuff)
 End If
Even when I force nd and nd2 to refer to the same node, boo evaluates as "false." What am I overlooking here?
Reply With Quote
Old 27-02-2009, 21:51
Alex's Avatar
Alex Alex is offline
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4

Many objects are just wrappers around internal objects/structures in CorelDRAW. In most cases, a new VBA object is returned that still points to the same underlying data. There are only a few cases where the same CorelDRAW object has one and only one VBA object. Such classes are Application, Document, Page, Layer, Shape. Can't think of any others even though there might be.

Other than those, you can't use VBA's "Is" keyword to see if the objects refer to the same CorelDRAW object. You will need to use other means. In your case, I would check AbsoluteIndex property of a node returned:

boo = (nd.AbsoluteIndex = nd2.AbsoluteIndex)
Reply With Quote
Old 01-03-2009, 12:41
Sablesword Sablesword is offline
Junior Member
Join Date: Aug 2006
Posts: 20

OK. Thanks for the explaination & the suggestion.
Reply With Quote

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Checking folders and subfolders mateushenrico CorelDRAW/Corel DESIGNER VBA 1 21-02-2009 00:31
Returning values/variables from functions m31uk3 Code Critique 2 02-01-2008 08:38
Checking fill type knowbodynow CorelDRAW/Corel DESIGNER VBA 2 08-03-2006 02:18
Global Variables ddonnahoe CorelDRAW/Corel DESIGNER VBA 3 08-08-2005 16:10
Reset All Variables ddonnahoe Code Critique 0 06-01-2005 07:16

All times are GMT -5. The time now is 03:50.

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright © 2011, Oberonplace.com