MapWindow 4 - ActiveX Control Programming : MapWindow Discussion Forum
Hi I need to chose one shape from a shapefile whit a mouse click. I try with this code (in VB6): Private Sub Map1_Mouseup(ByVal Button As Integer, ByVal Shift As Integer, ByVal X_MAP As Long, ByVal Y_MAP As Long) Dim X, Y, A, B As Double
PixelToProj problem
Posted by: Rodorc ()
Date: April 19, 2011 07:51AM

Hi

I need to chose one shape from a shapefile whit a mouse click. I try with this code (in VB6):


Private Sub Map1_Mouseup(ByVal Button As Integer, ByVal Shift As Integer, ByVal X_MAP As Long, ByVal Y_MAP As Long)

Dim X, Y, A, B As Double


If Map1.CursorMode = cmSelection Then

X = CDbl(X_MAP)
Y = CDbl(Y_MAP)

Map1.PixelToProj X, Y, A, B

MsgBox ("X= " & X & " Y= " & Y)

End If

End Sub


But sendme error : "Run-time error:'13' Type Mismatch"

¿Some one know what happend?, thanks for the support


PD: I speak spanish, and my english is'nt very good.

Options: ReplyQuote
Re: PixelToProj problem
Posted by: bmarch ()
Date: April 19, 2011 09:08AM

Hi Rodorc,

You might want to try this:

MsgBox ("X= " & CStr(X) & " Y= " & CStr(Y) )

Thats the only place that I see a type mismatch in your code.

Are you sure that PixelToProj X, Y, A, B takes four double as inputs and not four longs I can't remember of hand but thats where I would look next.

Brian M.

Options: ReplyQuote
Re: PixelToProj problem
Posted by: Rodorc ()
Date: April 19, 2011 09:26AM

Hi Brian,

The error is not in the MsgBox line, if i put in comment the line with PixelToProj, the Msgbox and the code work.

The error must be in the PixelToProj line, but i browse for this function, and the X and Y variables must be Double.

Thanks for your support.


Rodorc

Options: ReplyQuote
Re: PixelToProj problem
Posted by: bmarch ()
Date: April 19, 2011 10:49AM

Hi Rodorc,

Try this:

Dim X as double = CDbl(X_MAP)
Dim Y as double = CDbl(Y_MAP)
Dim A as double = 0.0
Dim B as double = 0.0

Map1.PixelToProj(X, Y, A, B)

MsgBox("X= " & X & " Y= " & Y)

Options: ReplyQuote
Re: PixelToProj problem
Posted by: Rodorc ()
Date: April 19, 2011 01:01PM

Hi bmarch

It work perfect......

The code now is:


Private Sub Map1_Mouseup(ByVal Button As Integer, ByVal Shift As Integer, ByVal X_MAP As Long, ByVal Y_MAP As Long)

Dim X As Double
Dim Y As Double
Dim A As Double
Dim B As Double

X = CDbl(X_MAP)
Y = CDbl(Y_MAP)
A = 0# ' 0.0
B = 0# ' 0.0


If Map1.CursorMode = cmSelection Then

Map1.PixelToProj X, Y, A, B

MsgBox ("A= " & A & " B= " & B) ' to confirm A anf B values

End If

End Sub



Thanks a lot.


Rodorc

Options: ReplyQuote
Re: PixelToProj problem
Posted by: dropsyy ()
Date: May 16, 2011 08:39AM

How can I do this in C#

Options: ReplyQuote


Sorry, only registered users may post in this forum.





Banner Exchange




GISCP.com




Send us your banner logo (160x120) for the space above, and add this MapWindow banner ad to your site:

Just paste this text in your page: