.NET

Reply
Valued Contributor
gizmowiebe
Posts: 57
Registered: ‎10-21-2003
Message 1 of 5 (218 Views)

VB routine to VB.NET

218 Views, 4 Replies
05-28-2009 04:32 AM
Hello,

I have a few years experience working with VB6 and VBA in combination with AutoCad. Now due to various reasons I would like to switch to VB.NET. For that I have downloaded Visual Basic 2008 Express.

Attached I added a VB routine that I would like to use in Visual Basic 2008 Express.

Does anybody know how to convert this

Thx in advance.

Wiebe
Distinguished Contributor
fantum
Posts: 313
Registered: ‎12-06-2004
Message 2 of 5 (218 Views)

Re: VB routine to VB.NET

05-28-2009 07:20 AM in reply to: gizmowiebe
If you just want to get this into VB.NET pretty much as is then:

1) Create a new project.
2) Paste the code into a suitable place - a button click event in a windows app or Sub Main() of a console app.
3) Add references to the AutoCAD and AutoCAD/ObjectDBX type libraries.
4) Import the namespaces you'll be using (unless you want to fully qualify everything) - Autodesk.AutoCAD.Interop and Autodesk.AutoCAD.Interop.Common.
5) Declare your undeclared variables.
6) Fix your unterminated If blocks and For loop.
7) Enjoy.

Caution: Contents may be hot. Your mileage may vary. Results may not be typical.

No bytes were harmed during the production of this post.
Valued Contributor
gizmowiebe
Posts: 57
Registered: ‎10-21-2003
Message 3 of 5 (218 Views)

Re: VB routine to VB.NET

05-28-2009 07:56 AM in reply to: gizmowiebe
Thx fantum for your prompt reply.

I got as far as the function attached. But everytime I get a HRESULT: 0x8007007E error on the blockreference parts.

Any ideas?

Regards

Wiebe
*Expert Elite*
arcticad
Posts: 1,286
Registered: ‎06-21-2004
Message 4 of 5 (218 Views)

Re: VB routine to VB.NET

05-28-2009 08:20 AM in reply to: gizmowiebe
Since you are Late Bound you don't have any type defined.
Use typename instead.

{code}
For Each entity In dbxDoc.ModelSpace
If TypeName(entity) = "IAcadBlockReference" Then
MsgBox(entity.name)
End If
Next entity
{code}
---------------------------



(defun botsbuildbots() (botsbuildbots))
Distinguished Contributor
fantum
Posts: 313
Registered: ‎12-06-2004
Message 5 of 5 (218 Views)

Re: VB routine to VB.NET

05-28-2009 08:36 AM in reply to: gizmowiebe
Is there a reason for using late binding?
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.