求教关于读取扩展数据的问题
从C#的代码转换到VB.NET的,如果选择带有扩展数据的对象,程序能正常运行,但是如果对象不包含扩展数据,就会导致CAD崩溃。我想原因是不是出在Not IsDBNull(resBuf) 这一句上,C#为(resBuf != null),我这样转换不对吗?求解Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
Dim acCurDb As Database = acDoc.Database
Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction
Dim acEntityOpts As PromptEntityOptions = New PromptEntityOptions("")
Dim acEntityRsl As PromptEntityResult = acDoc.Editor.GetEntity(acEntityOpts)
Dim acEnt As Entity = acTrans.GetObject(acEntityRsl.ObjectId, OpenMode.ForRead, True)
Dim resBuf As ResultBuffer = acEnt.XData
If Not IsDBNull(resBuf) Then
Dim iter As IEnumerator = resBuf.GetEnumerator()
While iter.MoveNext()
Dim tmpVal As TypedValue = iter.Current
acDoc.Editor.WriteMessage(vbLf & tmpVal.TypeCode.ToString & ":" & tmpVal.Value.ToString())
End While
End If
End Using
你把isdbnull这一句换成isnothing试试?我也没怎么使用VB,也不是太了解,希望能帮到你 cdinten 发表于 2014-4-3 22:13 static/image/common/back.gif
你把isdbnull这一句换成isnothing试试?我也没怎么使用VB,也不是太了解,希望能帮到你
改成isnothing就没有问题了,感谢 wuqiu1986 发表于 2014-4-4 12:49 static/image/common/back.gif
改成isnothing就没有问题了,感谢
居然被我蒙对了?哈哈
页:
[1]