+ Reply to Thread
Results 1 to 4 of 4

Using classes to store user credentials

  1. #1
    Philippe Pons
    Guest

    Using classes to store user credentials

    Hi,

    I consider using a class to store if the user has been authorized.
    Something like:
    Dim thisUser as new clsUser
    thisUser.IsAuthorized = True

    But I don't know how to preserve this instance of the class, together with
    it's properties, throughout the life of the application.

    Could you help me?

    Thank's in advance

    Philippe



  2. #2
    Chip Pearson
    Guest

    Re: Using classes to store user credentials

    Create a Collection object as a global variable (declared outside
    of and prior to any procedure in the module), and then use
    Set/New to create an instance of your class, then store that
    instance in the collection. E.g.,


    Dim MyUsers As New Collection

    Sub MySub()
    Dim thisUser As clsUser
    Set thisUser = New clsUser
    MyUsers.Add thisUser
    End Sub


    --
    Cordially,
    Chip Pearson
    Microsoft MVP - Excel
    Pearson Software Consulting, LLC
    www.cpearson.com




    "Philippe Pons" <Philippe.Pons19_nospam@wanadoo.fr> wrote in
    message news:ey2B45CmFHA.3288@TK2MSFTNGP09.phx.gbl...
    > Hi,
    >
    > I consider using a class to store if the user has been
    > authorized.
    > Something like:
    > Dim thisUser as new clsUser
    > thisUser.IsAuthorized = True
    >
    > But I don't know how to preserve this instance of the class,
    > together with
    > it's properties, throughout the life of the application.
    >
    > Could you help me?
    >
    > Thank's in advance
    >
    > Philippe
    >
    >




  3. #3
    Philippe Pons
    Guest

    Re: Using classes to store user credentials

    Thank you Chip,

    A further question if you mind.
    How can I get to the thisUser properties later on, I mean during execution
    of a diffrent procedure.
    If I write: MyUsers.thisUser.someProp, I get an error that MyUsers is
    undefined!

    TIA,
    Philippe

    "Chip Pearson" <chip@cpearson.com> a écrit dans le message de
    news:%23pQ4YJDmFHA.3828@TK2MSFTNGP12.phx.gbl...
    > Create a Collection object as a global variable (declared outside
    > of and prior to any procedure in the module), and then use
    > Set/New to create an instance of your class, then store that
    > instance in the collection. E.g.,
    >
    >
    > Dim MyUsers As New Collection
    >
    > Sub MySub()
    > Dim thisUser As clsUser
    > Set thisUser = New clsUser
    > MyUsers.Add thisUser
    > End Sub
    >
    >
    > --
    > Cordially,
    > Chip Pearson
    > Microsoft MVP - Excel
    > Pearson Software Consulting, LLC
    > www.cpearson.com
    >
    >
    >
    >
    > "Philippe Pons" <Philippe.Pons19_nospam@wanadoo.fr> wrote in
    > message news:ey2B45CmFHA.3288@TK2MSFTNGP09.phx.gbl...
    > > Hi,
    > >
    > > I consider using a class to store if the user has been
    > > authorized.
    > > Something like:
    > > Dim thisUser as new clsUser
    > > thisUser.IsAuthorized = True
    > >
    > > But I don't know how to preserve this instance of the class,
    > > together with
    > > it's properties, throughout the life of the application.
    > >
    > > Could you help me?
    > >
    > > Thank's in advance
    > >
    > > Philippe
    > >
    > >

    >
    >




  4. #4
    Chip Pearson
    Guest

    Re: Using classes to store user credentials

    You need to access the Collection item. E.g.,

    MyUsers(1).SomeProp


    --
    Cordially,
    Chip Pearson
    Microsoft MVP - Excel
    Pearson Software Consulting, LLC
    www.cpearson.com



    "Philippe Pons" <Philippe.Pons19_nospam@wanadoo.fr> wrote in
    message news:OHefkVDmFHA.572@TK2MSFTNGP15.phx.gbl...
    > Thank you Chip,
    >
    > A further question if you mind.
    > How can I get to the thisUser properties later on, I mean
    > during execution
    > of a diffrent procedure.
    > If I write: MyUsers.thisUser.someProp, I get an error that
    > MyUsers is
    > undefined!
    >
    > TIA,
    > Philippe
    >
    > "Chip Pearson" <chip@cpearson.com> a écrit dans le message de
    > news:%23pQ4YJDmFHA.3828@TK2MSFTNGP12.phx.gbl...
    >> Create a Collection object as a global variable (declared
    >> outside
    >> of and prior to any procedure in the module), and then use
    >> Set/New to create an instance of your class, then store that
    >> instance in the collection. E.g.,
    >>
    >>
    >> Dim MyUsers As New Collection
    >>
    >> Sub MySub()
    >> Dim thisUser As clsUser
    >> Set thisUser = New clsUser
    >> MyUsers.Add thisUser
    >> End Sub
    >>
    >>
    >> --
    >> Cordially,
    >> Chip Pearson
    >> Microsoft MVP - Excel
    >> Pearson Software Consulting, LLC
    >> www.cpearson.com
    >>
    >>
    >>
    >>
    >> "Philippe Pons" <Philippe.Pons19_nospam@wanadoo.fr> wrote in
    >> message news:ey2B45CmFHA.3288@TK2MSFTNGP09.phx.gbl...
    >> > Hi,
    >> >
    >> > I consider using a class to store if the user has been
    >> > authorized.
    >> > Something like:
    >> > Dim thisUser as new clsUser
    >> > thisUser.IsAuthorized = True
    >> >
    >> > But I don't know how to preserve this instance of the class,
    >> > together with
    >> > it's properties, throughout the life of the application.
    >> >
    >> > Could you help me?
    >> >
    >> > Thank's in advance
    >> >
    >> > Philippe
    >> >
    >> >

    >>
    >>

    >
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1