Problem with VB.NET script using ArcGIS library

Greetings,

I am trying to figure out why I am receiving the pApp = Application not declared error.  We are trying to convert over VBA code to VB.NET and I was wondering if that had anything to do with the error.  The pAPP=Application is located in the middle of the code.

Any suggestions or what I should be looking at would be greatly appreciated.

Thanks!!

Heather

GoogleMap_Link.vb

 

Imports ESRI.ArcGIS.ArcMapUI

Imports ESRI.ArcGIS.Desktop

Imports ESRI.ArcGIS.Geometry

Imports ESRI.ArcGIS.Carto

Imports ESRI.ArcGIS.Geodatabase

 

Module GoogleMap_Link

    'This VBA code came from Bert Granberg, of Utah GIS.

    'http://gis.utah.gov/code-visual-basic/vba-link-from-arcmap-to-google-maps

 

    Const SW_SHOWMAXIMIZED = 3

    Const SW_SHOWMINIMIZED = 2

    Const SW_SHOWDEFAULT = 10

    Const SW_SHOWMINNOACTIVE = 7

    Const SW_SHOWNORMAL = 1

 

    Private Declare Function ShellExecute Lib "shell32.dll" _

    Alias "ShellExecuteA" (ByVal hWnd As Long, _

    ByVal lpOperation As String, ByVal lpFile As String, _

    ByVal lpParameters As String, ByVal lpDirectory As String, _

    ByVal nShowCmd As Long) As Long

 

 

    Private Function OpenLocation(ByVal URL As String, ByVal WinState As Long) As Long

 

        'PURPOSE: Opens default browser to display URL

 

        'RETURNS: module handle to executed application or

        'Error Code ( < 32) if there is an error

 

        'can also be used to open any document associated with

        'an application on the system (e.g., passing the name

        'of a file with a .doc extension will open that file in Word)

 

        Dim lHWnd As Long

        Dim lAns As Long

 

        lAns = ShellExecute(lHWnd, "open", URL, vbNullString, _

        vbNullString, WinState)

 

        OpenLocation = lAns

 

        'ALTERNATIVE: if not interested in module handle or error

        'code change return value to boolean; then the above line

        'becomes:

 

        'OpenLocation = (lAns > 32)

 

    End Function

 

 

    Private Sub GoogleMap_Link_MouseDown(ByVal button As Long, ByVal shift _

             As Long, ByVal x As Long, ByVal y As Long)

 

        Dim pMxDoc As IMxDocument

        Dim pApp As IMxApplication

        Dim pMap As IMap

        Dim pPoint As IPoint

        Dim pSpatialReferenceFactory As ISpatialReferenceFactory

        Dim pSpatialReference As ISpatialReference

 

        pMxDoc = My.ArcMap.Document

        pMap = pMxDoc.FocusMap

        pApp = Application

 

        pSpatialReferenceFactory = New SpatialReferenceEnvironment

        pSpatialReference = pSpatialReferenceFactory.CreateGeographicCoordinateSystem(4326)

        ' OLD CODE: CreateGeographicCoordinateSystem(esriSRGeoCS_WGS1984)

 

        ' convert mouse click to map units

 

        pPoint = pApp.Display.DisplayTransformation.ToMapPoint(x, y)

        pPoint.SpatialReference = pMap.SpatialReference

        If pPoint.SpatialReference.Name <> pSpatialReference.Name Then

            pPoint.Project(pSpatialReference)

 

        End If

 

        Dim URLstr As String

        Dim returnLong As Long

 

        'more info on google map URL query string request setting parameters:

        'http://mapki.com/index.php?title=Google_Map_Parameters

 

        '==========

        'This script came from MapChannels, a free, online mashup generator.

        'We may have to reverse engineer the split-screen design if they ever

        'decide to remove it from their server.

 

        URLstr = "http://data.mashedworld.com/dualmaps/map.htm?x=" & _

            pPoint.X & "&y=" & pPoint.Y & _

            "&z=16&gm=0&ve=5&gc=0&bz=1&bd=0&mw=1&sv=1&svb=0&svp=0&svz=0&svm=1&svf=1"

 

        '==========

 

        'STREET VIEW USE THIS FUNCTION

        ' URLstr = "http://www.google.com/maps?ie=UTF8&layer=c&cbll=" & _

        '         pPoint.y & "," & pPoint.x & "&cbp=12,0,,0,5&ll=" & pPoint.y _

        '         & "," & pPoint.x & "&z=16"

 

 

        'REGULAR MAP USE THIS FUNCTION ... NO STREETVIEW WINDOW

        'URLstr = "http://www.google.com/maps?ie=UTF8&ll=" & pPoint.y _ & "," & pPoint.x & "&spn=0.015045,0.016844&z=16"

 

        'Use one of the constants as the window state parameter

        returnLong = OpenLocation(URLstr, SW_SHOWNORMAL)

 

    End Sub

 

    ' SAMPLE CODE OFF WEB: Private Sub OpenURL(ByVal URL As String)

    ' System.Diagnostics.Process.Start("http://www.mredkj.com")

    ' End Sub

 

End Module
Heather_DAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

RobSampsonCommented:
Hi, just taking a stab in the dark, but if you go by this:
http://edndoc.esri.com/arcobjects/8.3/componenthelp/esricore/IMxApplication.htm

then change this:
pApp = Application

to this:
Set pApp = Application

should get past that error.

Rob.
0
Heather_DAuthor Commented:
Thank Rob!  I'll give this a shot and get back to you!

Thanks for your help!!

Heather
0
Heather_DAuthor Commented:
declare-error-HM.docx

Hi Rob,

When I change the name to Set pApp = Application it defaults back the original pApp = Application.  When I click on the declare options, I get the list listed below.  
This seems like an easy error...not sure why it's not working.

I appreciate the help and any suggestions!!

Heather

0
IT Pros Agree: AI and Machine Learning Key

We’d all like to think our company’s data is well protected, but when you ask IT professionals they admit the data probably is not as safe as it could be.

Heather_DAuthor Commented:
Rob,

I looked into this and go it to work.  I replaced the
pApp = Application

with

pApp = My.ArcMap.Application

and it worked or at least I don't have the error anymore.  

Thanks for your help on this!

Heather
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Heather_DAuthor Commented:
I figured out the solution using google.

Thanks for the help!!!

Heather
0
Heather_DAuthor Commented:
Thanks again!!
0
RobSampsonCommented:
Good to hear.

Rob.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.