阅读:1266回复:0
[求助]vb6的程序如何升级至VB.NET
<P>以下是VB6的源程序,</P>
<P>Private Sub Map1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)<BR> Dim ly1 As MapObjects2.MapLayer<BR> Dim fld As MapObjects2.Field<BR> Dim newItem As Object<BR> Dim p As MapObjects2.Point<BR> Dim Recs As MapObjects2.Recordset<BR> <BR> Set ly1 = Map1.Layers("States")<BR> Set p = Map1.ToMapPoint(x, y)<BR> Set Recs = ly1.SearchShape(p, moPointInPolygon, "")<BR> If Not Recs.EOF Then<BR> ListView1.ListItems.Clear<BR> For Each fld In Recs.Fields ' iterate over the fields<BR> Set newItem = ListView1.ListItems.Add<BR> newItem.Text = fld.Name<BR> newItem.SubItems(1) = fld.ValueAsString ' get the value<BR> Next fld<BR> End If<BR>End Sub</P> <P>当我在VB.net中改为如下,编译通不过,请大侠们指点一二。</P> <P> Private Sub Map1_MouseDownEvent(ByVal sender As System.Object, ByVal e As AxMapObjects2._DMapEvents_MouseDownEvent) Handles Map1.MouseDownEvent<BR> Dim curRectangle As MapObjects2.Rectangle<BR> Dim pt As MapObjects2.Point<BR> curRectangle = Map1.TrackRectangle<BR> Map1.Extent = curRectangle<BR> pt = Map1.ToMapPoint(X, y)<BR> Map2.CenterAt(pt.X, pt.Y)</P> <P> Dim r As MapObjects2.Rectangle<BR> If ToolBarButton1.Pushed Then<BR> Map1.Extent = Map1.TrackRectangle<BR> ElseIf ToolBarButton3.Pushed Then<BR> Map1.Pan()<BR> ElseIf ToolBarButton2.Pushed Then<BR> r = Map1.Extent<BR> r.ScaleRectangle(1.5)<BR> Map1.Extent = r<BR> End If<BR> End Sub</P> |
|