Best Method?? Global Variable creation, guidence appreciated.

  • Thread starter Thread starter Dan
  • Start date Start date
D

Dan

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
registry.
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.

i.e.
'-snip
Dim issuedTS As String
issuedTS = InputBox("Enter Issued Description:", " Issued Description",
issuedTS)
'-snip

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

Thanks for the advice,

Dan
 
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",
issuedTS)
End Sub
 
That wil work, I forgot about that, sorry...
Ed Jobe said:
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",
issuedTS)
End Sub
 
Back
Top