Results 1 to 6 of 6

Thread: Module Scope variables...

  1. #1

    Thread Starter
    Fanatic Member simonm's Avatar
    Join Date
    Sep 2000
    Location
    Devon, England
    Posts
    796

    Resolved Module Scope variables...

    I have a some variables that are declared in a vb webform class outside of any procedure. But when I set their values in one procedure, these variables are re-initialised when I access them in another procedure.

    Is it not possible to use module scope variables in this way in webforms?

    Perhaps I would be better creating session variables instead?
    Last edited by simonm; Apr 22nd, 2005 at 06:59 AM.
    Everything I say is either loose interpretation of dubious facts or idle speculation rooted in irrational sentiment.

  2. #2
    Hyperactive Member GlenW's Avatar
    Join Date
    Nov 2001
    Location
    Gateshead, England
    Posts
    479

    Re: Module Scope variables...

    Declare them as 'shared' then you only have one instantiation of them.
    I am assuming that vb 'shared' is the same as c# 'static'.

  3. #3

    Thread Starter
    Fanatic Member simonm's Avatar
    Join Date
    Sep 2000
    Location
    Devon, England
    Posts
    796

    Re: Module Scope variables...

    What will they be shared with? I don't want them shared with other sessions.
    Everything I say is either loose interpretation of dubious facts or idle speculation rooted in irrational sentiment.

  4. #4
    Hyperactive Member GlenW's Avatar
    Join Date
    Nov 2001
    Location
    Gateshead, England
    Posts
    479

    Re: Module Scope variables...

    If you want variables to be accessible between post backs but not accessible to other sessions then use session variables.
    If you only want them to hold their values during a single instantiation of your class then declare them as normal in your class.

  5. #5

    Thread Starter
    Fanatic Member simonm's Avatar
    Join Date
    Sep 2000
    Location
    Devon, England
    Posts
    796

    Re: Module Scope variables...

    Oh I see...they get re-initialised every postback.
    Everything I say is either loose interpretation of dubious facts or idle speculation rooted in irrational sentiment.

  6. #6
    Hyperactive Member GlenW's Avatar
    Join Date
    Nov 2001
    Location
    Gateshead, England
    Posts
    479

    Re: Module Scope variables...

    Another way to store variable values is to use the view state, that way they are stored by the client. OK for small values.

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