I have some code I wrote in 9.3 that (mostly) works in version 10. I have a UIToolControl that buffers a user-input point based on a mouse click - nearly identical to the sample.
This used to work fine. Now I get an error - "Invalid use of New keyword" when the code tries to create a new Point from which to buffer.
Both the sample and my code work fine in a blank MXD (I have to comment out the CountElements.CountElementsInMap line which refers to another procedure), but not in this one.
Is there a conflict between some other variable that may be hanging out in memory space? I cannot find one and this fails even if it is the first thing I do.
Private Sub UIToolControl1_MouseDown(ByVal button As Long, ByVal shift As Long, _ ByVal x As Long, ByVal y As Long) 'Stop Dim pDoc As IMxDocument Dim pMap As IMap Dim pAV As IActiveView Set pDoc = ThisDocument Set pMap = pDoc.FocusMap Set pAV = pDoc.FocusMap Dim pPoint As IPoint Set pPoint = New Point 'Fails right here - Invalid use of New keyword Set pPoint = pDoc.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y) Dim pGC As IGraphicsContainer Dim pGCS As IGraphicsContainerSelect Dim pElem As IElement Dim pElemProp As IElementProperties Set pGC = pMap Set pElem = New MarkerElement pElem.Geometry = pPoint Set pElemProp = pElem pElemProp.Name = "BufferPoint" pGC.AddElement pElem, 0 Set pGCS = pMap pGCS.SelectElement pElem 'Stop 'CountElements.CountElementsInMap Dim pCmdBar As ICommandBar Dim pCmdItem As ICommandItem Dim pUID As New UID Set pCmdItem = Document.CommandBars.Find(ArcID.PageLayout_SelectTool) Set Document.Parent.CurrentTool = pCmdItem 'pAV.Refresh End Sub
Thanks in advance for any help! Dan