• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    .NET

    Reply
    Active Contributor
    Posts: 49
    Registered: ‎10-21-2003

    VB routine to VB.NET

    164 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
    Please use plain text.
    Distinguished Contributor
    Posts: 313
    Registered: ‎12-06-2004

    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.
    Please use plain text.
    Active Contributor
    Posts: 49
    Registered: ‎10-21-2003

    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
    Please use plain text.
    *Expert Elite*
    arcticad
    Posts: 1,250
    Registered: ‎06-21-2004

    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}
    ---------------------------



    “We don’t have a snowball’s chance in a blast furnace of surviving this attack unless every one of our units gets into the fight right now!”
    Please use plain text.
    Distinguished Contributor
    Posts: 313
    Registered: ‎12-06-2004

    Re: VB routine to VB.NET

    05-28-2009 08:36 AM in reply to: gizmowiebe
    Is there a reason for using late binding?
    Please use plain text.