Jan 23, 2012

How Do I Get the Sum of Text Numbers Using Autocad VBA?

,
The AutoCAD program installed on your computer includes a "Command" section that allows you to execute Visual Basic for Applications expressions, such as the addition of text numbers, without exiting the AutoCAD window. However, the VBA functionality is not included with AutoCAD by default, and must first be installed before you can execute commands. Once the file has been downloaded and installed, you can use the "Command" section to write and execute VBA expressions.


Instructions

    • 1
      Launch AutoCAD.
    • 2
      Click inside the "Command" section at the bottom of the window.
    • 3
      Type "Vbaload," then press "Enter" on your keyboard.
    • 4
      Click the "http://www.autodesk.com/vba-download" link in the pop-up window.
    • 5
      Click the "AutoCAD VBA Module" link at the center of the window for your version of AutoCAD, then save the file to your computer. If you don't know your AutoCAD version, you can click "Help" at the top of your AutoCAD window, then click "About." The version is displayed at the top of the window.
    • 6
      Close AutoCAD.
    • 7
      Double-click the downloaded file, then follow the prompts to complete the installation.
    • 8
      Launch AutoCAD.
    • 9
      Click inside the "Command" section at the bottom of the window again, type "Vbastmt," then press "Enter" on your keyboard. This will display an "Expression:" prompt in the "Command" section.
    • 10
      Copy and paste the VBA code to prompt you for two text numbers, then display the total once both of the numbers have been entered:
      Sub autocadsumnumbers()
      Dim autocadinput1 As Integer
      Dim autocadinput2 As Integer
      Dim intSum As Integer
      autocadinput1 = Val(InputBox("First Number"))
      autocadinput2 = Val(InputBox("Second Number"))
      autocadSum = autocadinput1 + autocadinput2
      MsgBox autocadSum
      End Sub

0 commentaires to “How Do I Get the Sum of Text Numbers Using Autocad VBA?”

Post a Comment

 

HowToYo Copyright © 2011 | Template design by O Pregador | Powered by Blogger Templates