阅读:1510回复:4
大家帮忙看看我的代码吧!
<P>大家帮我看一下我的代码吧,我要实现的是读取.shp文件以及文件的.DBF表格。刚刚学的vb.net,很多东西还不是很明白,大家帮个忙吧!其中红色字体部分是在调试的过程中出错的地方,以及写程序的过程中不明白的地方。多谢了!^_^</P>
<P>Public Class Practice<BR> Inherits System.Windows.Forms.Form</P> <P> Public Interface IWorkspace<BR> Property Prop1()<BR> Event Event1()<BR> End Interface<BR> </P> <P> Public Interface IFeature<BR> Property Value()<BR> Property Fields()<BR> Function FindField()<BR> End Interface<BR> </P> <P> Public Interface IWorkspaceFactory<BR> Property ShapefileWorkspaceFactory()<BR> Function OpenFromFile()<BR> End Interface<BR> </P> <P> Public Interface IFeatureWorkspace<BR> Function OpenFeatureClass()<BR> End Interface<BR> </P> <P> Public Interface IFeatureClass<BR> ReadOnly Property Fields()<BR> Function Search()<BR> Event FindField()<BR> End Interface<BR> </P> <P> Public Interface IFeatureCursor<BR> Function NextFeature()<BR> End Interface<BR> </P> <P> Public Interface IQueryFilter<BR> Property WhereClause() As String<BR> End Interface<BR> Public Function IsNull()</P> <P> End Function</P> <P> Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click<BR> '<FONT color=#f70909>要想实现单击Button就可以实现下面的功能这里还需要什么?</FONT><BR> End Sub<BR> Public Sub test(ByVal columName As String, ByVal shapeFileName As String, ByVal shapeFilePath As String)<BR> Dim pWorkSpaceFact As IWorkspaceFactory<BR> Dim pWorkSpace As IWorkspace<BR> Dim pFeatureWorkspace As IFeatureWorkspace<BR> pWorkSpaceFact = New ShapefileWorkspaceFactory '<FONT color=#ff0000>为什么这里总是显示未定义类型<BR></FONT> pWorkSpace = pWorkSpaceFact.OpenFromFile(shapeFilePath, 0)<BR> pFeatureWorkspace = pWorkSpace<BR> Dim pFeatureClass As IFeatureClass<BR> pFeatureClass = pFeatureWorkspace.OpenFeatureClass(shapeFileName)<BR> Dim pFeatcur As IFeatureCursor<BR> Dim pFeat As IFeature<BR> Dim pQueryFilter As IQueryFilter<BR> pQueryFilter = New QueryFilter '<FONT color=#ff0000>这里也是显示的未定义类型<BR></FONT> pQueryFilter.WhereClause = "E:\新建文件夹 (2)"<BR> pFeatcur = pFeatureClass.Search(pQueryFilter, False)<BR> pFeat = pFeatcur.NextFeature<BR> Dim value As String<BR> Do Until pFeat Is Nothing<BR> If Not IsNull(pFeat.Value(pFeat.Fields(columName))) Then<BR> value = pFeat.Value(pFeat.Fields(columName))<BR> Debug.Print(value) ' <FONT color=#ff0000>“Print”不是“System.Diagnostics.Debug”的成员。</FONT></P> <P><FONT color=#ff0000> End If</FONT></P> <P> pFeat = pFeatcur.NextFeature<BR> Loop<BR> End Sub<BR>End Class</P> |
|
1楼#
发布于:2007-05-24 17:28
引用了相关的dll吗?
|
|
|
2楼#
发布于:2007-05-24 19:19
没有!这就是我的全部代码了!
|
|
3楼#
发布于:2007-05-24 23:50
<P>我的意思是你引用了你用到的AE的库吗?另外你的代码输出的详细错误信息是什么?</P>
|
|
|
4楼#
发布于:2007-05-25 09:03
<P>“DefaultDomain”: 已加载“c:\windows\microsoft.net\framework\v1.1.4322\mscorlib.dll”,未加载符号。<BR>“practice”: 已加载“c:\windows\assembly\gac\mscorlib.resources\1.0.5000.0_zh-chs_b77a5c561934e089\mscorlib.resources.dll”,未加载符号。<BR>“practice”: 已加载“E:\VB编程要用\vb.net\practice\practice\bin\practice.exe”,符号已加载。<BR>“practice.exe”: 已加载“c:\windows\assembly\gac\system.windows.forms\1.0.5000.0__b77a5c561934e089\system.windows.forms.dll”,未加载符号。<BR>“practice.exe”: 已加载“c:\windows\assembly\gac\system\1.0.5000.0__b77a5c561934e089\system.dll”,未加载符号。<BR>“practice.exe”: 已加载“c:\windows\assembly\gac\system.drawing\1.0.5000.0__b03f5f7f11d50a3a\system.drawing.dll”,未加载符号。<BR>程序“[2612] practice.exe”已退出,返回值为 0 (0x0)</P>
<P>这就是输出时的详细的错误信息了,我没有引用库!</P> <P>另外在任务列表中显示的错误信息就是我的代码中用红色字体标识的部分!</P> |
|