Results 1 to 4 of 4

Thread: Problem referencing a public variable

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2000
    Posts
    3
    I have an MDI form called mdiMain. In it I declare
    Public test as Boolean
    mdiMain calls another form and within a method in that form I set 'test' to true. When I run it I get a compiler error that 'test' is not defined. However if I set 'mdiMain.test' to true it works. I don't understand this.

  2. #2
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    It's a public variable, so it can be accessed between modules, but you still need to tell where the variable was declared(or whatever, if "declared" is the wrong word...). that's why you need to say mdiMain.test
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  3. #3
    Lively Member
    Join Date
    Oct 2000
    Location
    Chicago
    Posts
    97
    If you declare the variable as public in the standard module then you can refer it without giving the form name but when you give public even in the MDI form you have to refer it with the form name.The final saying is that even though you declare the variable as public in forms,you have to access them with the form name but when you declare it in the std module then it will be visible to the whole project.
    Anil

  4. #4

    Thread Starter
    New Member
    Join Date
    Nov 2000
    Posts
    3
    Thank you for the responses. This way of handling public variables seems strange to me, but I can live with it.

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