Best Method?? Global Variable creation, guidence appreciated.

Discussion in 'AutoCAD' started by Dan, Oct 18, 2004.

  1. Dan

    Dan Guest

    As I have stated before, I am rather new to VBA, and have learned very much
    from this NG. Thanks.

    I am currently researching methods of Variable creation.
    I know I can create a variable from user input, and place it into the
    I know through VB, I can create variable into an .ini file.

    Let me just state what I am trying to do.

    I have a piece of text in my titleblock(paperspace) that changes it issued
    text, depending on the situation.

    I have created some code to modify text for the 2 most often occurrences,
    but there are many times it will be specific.
    (Because there can be 50+ dwgs, that are individual, I cannot simply add it
    into the xref'd titleblock.)

    I would like to create a MSBOX, and have it prompt the user for input, which
    will become a text string variable, and be retrievable until autocad is
    closed, then it becomes nil. That way this code would have the string
    necessary for multiple drawings.

    Dim issuedTS As String
    issuedTS = InputBox("Enter Issued Description:", " Issued Description",

    If you have some examples/links/references in help of code, it would be
    greatly appreciated.

    Thanks for the advice,

    Dan, Oct 18, 2004
  2. Dan

    Ed Jobe Guest

    Go to help and search the index for "scope". All you need to do is use a
    variable that doesn't go out of scope until you close autocad. Instead of
    using Dim at the procedure level to declare a variable, declare it in the
    module's Declarations section as Public. This will not only make it
    available to all procedures in the project, but it will stay in scope until
    the project is unloaded, which is usually when acad closes...unless you are
    unloading before that.

    Option Explicit
    Public issuedTS As String

    Public Sub GetIssue ()
    issuedTS = InputBox("Enter Issued Description:", " Issued Description",
    End Sub
    Ed Jobe, Oct 18, 2004
  3. Dan

    Dan Guest

    That wil work, I forgot about that, sorry...
    Dan, Oct 18, 2004
  4. Dan

    Ed Jobe Guest

    No problem. :)

    Ed Jobe, Oct 19, 2004
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.