CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: Global Variable

  1. #1
    Guest

    Global Variable

    I have a standard EXE project and i want to declare global type to be known within all class moduls. If i define it as a public in a module or a class module i recieved an error message . What is the way to declare global types?
    Thanks


  2. #2
    Join Date
    Oct 1999
    Posts
    191

    Re: Global Variable

    I did it before, but I forgot. So I give two suggestions.

    1. pass parameter (I did in the past)
    2. store in a file or DB


    Hope this helps!
    ray

    http://homepages.msn.com/LibraryLawn/rayxu/
    (lots of code, tips, links, and more!)



  3. #3
    Join Date
    Apr 1999
    Location
    Netherlands
    Posts
    181

    Re: Global Variable

    What error do you get?
    I don't have problems when i say in a module
    Public Something As String
    I can access it in all modules and classes within that exe.

    Crazy D @ Work :-)

  4. #4
    Guest

    Re: Global Variable

    I cannot declare Public type SOMETHING
    End Type
    in the module section
    and then to use it in a module.


  5. #5
    Join Date
    Sep 1999
    Location
    Baytown, TX, United States
    Posts
    23

    Re: Global Variable

    Declare the variable in the General Declarations section of the form. When you got the form, click any command buttons, click on down arrow until you see "General" and select it.

    kazooie21

  6. #6
    Join Date
    Sep 1999
    Location
    Trivandrum, Kerala, INDIA.
    Posts
    32

    Re: Global Variable

    Had the same problem earlier!! Solved it by defining the components of my "type" structure in a User Defined Class.
    "Add" a Class Module to your project.
    In it, put


    public a as string
    public b as Integer
    ' more declarations here
    ' and some more here too




    You can use the features of VB to add functions to manipulate only the contets of your class variables.

    To make this class available in your project, define it where ever required, and "set" the class. You can even pass the classes as arguments to functions throughout your project.
    You can also refer to a post I had made earlier captioned "Class inheritance problems", or something like that. There were 2 posts - I forget the name of the first one!


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured