阅读:1780回复:3
帮我看看这段代码哪错了?
<P>我建了名为ClaAA的类如下:</P>
<P>Private pPage As IPageLayoutControl<BR><BR>Public Function yngc_fnMaxExtent() As esriGeometry.IEnvelope<BR> pPage.Page.Units = esriMillimeters<BR> <BR> Dim pLayer As esriCarto.IFeatureLayer<BR> Dim pFeatureClass As esriGeoDatabase.IFeatureClass<BR> Dim pGd As esriGeoDatabase.IGeoDataset</P> <P> Dim i As Integer<BR> Dim j As Integer<BR> Dim pEnv As esriGeometry.IEnvelope<BR> Set pEnv = New Envelope</P> <P> Dim pMaxEnv As esriGeometry.IEnvelope<BR> Set pMaxEnv = New Envelope</P> <P> Set pLayer = pPage.ActiveView.FocusMap.Layer(i)<BR> Set pFeatureClass = pLayer.FeatureClass<BR> Set pGd = pFeatureClass<BR> <BR> For i = 0 To pPage.ActiveView.FocusMap.LayerCount - 1<BR> If pPage.ActiveView.FocusMap.Layer(i).Name Like "netln*" Or pPage.ActiveView.FocusMap.Layer(i).Name Like "annpt*" Then<BR> <BR> Else<BR> Set pMaxEnv = pGd.Extent<BR> Exit For<BR> End If<BR> Next</P> <P> For j = i To pPage.ActiveView.FocusMap.LayerCount - 1<BR> If pPage.ActiveView.FocusMap.Layer(j).Name Like "netln*" Or pPage.ActiveView.FocusMap.Layer(j).Name Like "annpt*" Then<BR> <BR> Else<BR> Set pLayer = pPage.ActiveView.FocusMap.Layer(j)<BR> Set pFeatureClass = pLayer.FeatureClass<BR> Set pGd = pFeatureClass<BR> Set pEnv = pGd.Extent<BR> pMaxEnv.Union pEnv<BR> End If<BR> Next<BR> Set yngc_fnMaxExtent = pMaxEnv<BR>End Function</P> <P>Public Property Get PageLay() As IPageLayoutControl<BR> PageLay = pPage<BR>End Property</P> <P>Public Property Let PageLay(ByVal vNewValue As IPageLayoutControl)<BR> Set pPage = vNewValue<BR>End Property</P> <P>调用DLL时,我引用ClsAA.dll,新建窗体,在窗体上添加PageLayoutControl和按钮,按钮的事件如下:</P> <P>Private Sub Command1_Click()<BR>Dim a As ClsAA</P> <P>Set a.PageLay = PageLayoutControl1<BR>MsgBox a.yngc_fnMaxExtent.XMax<BR>End Sub</P> <P>运行程序老是出错,PageLayoutControl1的值不能传个PageLay不知道哪错了,帮帮忙!</P><img src="images/post/smile/dvbbs/em12.gif" /> |
|
1楼#
发布于:2005-09-28 08:45
你的参数不能写成ipagelayoutcontrol 要写成pagelayoutcontrol
|
|
2楼#
发布于:2005-09-28 10:01
<P>1、</P>
<P>Public Property Get PageLay() As IPageLayoutControl<BR> PageLay = pPage<BR>End Property</P> <P>加上Set</P> <P>Public Property Get PageLay() As IPageLayoutControl<BR> Set PageLay = pPage<BR>End Property</P> <P>2、创建ClsAA</P> <P>Set a=new ClsAA</P> <P>3、</P> <P>Set a.PageLay = PageLayoutControl1<BR>改为</P> <P>Set a.PageLay = PageLayoutControl1.object<BR></P> |
|
|
3楼#
发布于:2005-09-28 11:02
<P>还是不对,显示"对象变量或With块变量未设置"</P>
<img src="images/post/smile/dvbbs/em12.gif" /> |
|