Basic Code?

Discussion in 'AutoCAD' started by Mark Douglas, Apr 9, 2004.

  1. Mark Douglas

    Mark Douglas Guest

    Im a complete beginner when it comes to Vba. Does anyone have a Very Very
    Simple code that can show me some basics? Maybe some explanations on what's
    going on in the code also? Any help would be great!! One more thing is
    there, a "Load Selection" of some sort like in VLIDE. That way I can run
    each string of code to see what it does?. Thanks for any help!!!

    Mark
     
    Mark Douglas, Apr 9, 2004
    #1
  2. Start the editor, type ADDCIRCLE, and hit F1 to get to example code for
    adding a circle to a drawing. Just paste this subroutine into the
    ThisDrawing module.

    To step through code one line at a time, put your cursor in the subroutine
    and hit F8 to run each line. You may have to switch back to the ACAD window
    to get past any dialog boxes, etc.

    Browse through the help file, as almost all of the objects, methods, and
    properties have sample code.

    James
     
    James Belshan, Apr 9, 2004
    #2
  3. Mark Douglas

    Ed Jobe Guest

    In the "ActiveX and VBA Developer's Guide" there is tons of sample
    code...and instructions if you don't want to buy a book. To run code, make
    sure the Debug toolbar is displayed. It has buttons on it that look like
    standard Start, Pause, Stop icons. Click in the left margin of a line of
    code in your sub to set a breakpoint. Then click the Run button. Execution
    will start and break on the line where you set the breakpoint. Then use the
    button to the right of the Stop button to step through the code execution
    one line at a time. You can also enter short snippets in the Immediate
    window.
     
    Ed Jobe, Apr 9, 2004
    #3
  4. Mark Douglas

    Mark Douglas Guest

    Thanks Guys. Is there a window that says what each line value gives me? Like
    in Vlide? (getvar "DWGNAME") in other window says "Test.dwg)...This kind of
    thing?

    Mark
     
    Mark Douglas, Apr 9, 2004
    #4
  5. Mark Douglas

    Ed Jobe Guest

    That's the Immediate window. You can use Debug.Print to cause values to show
    up there. Any variables declared in your sub will show up in the Locals
    window. Anything more specific, you can set a Watch on and it shows up it
    the Watch window. All those buttons are also on the Debug toolbar.
     
    Ed Jobe, Apr 9, 2004
    #5
  6. If you set a breakpoint like Ed mentioned, then when the code pauses you can
    simply hold your mouse over an expression and its current value will show
    up.

    James
     
    James Belshan, Apr 9, 2004
    #6
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.