Static and Friend

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • webwing

    #1

    Static and Friend

    Hi,

    Can someone help please.

    Basicaly I need to read a registration number across several forms in
    my project.
    The user logs in and I will use this number accross the forms
    I have tried to store it in a Friend variable but once i hide the
    first form and go to the next form the value goes to 0.
    If I declare it Static then it is only usefull in one form.

    What is the best way to do this?

    Thanks

  • Jon Skeet [C# MVP]

    #2
    Re: Static and Friend

    webwing <webwing@uol.co m-dot-br.no-spam.invalid> wrote:[color=blue]
    > Can someone help please.
    >
    > Basicaly I need to read a registration number across several forms in
    > my project.
    > The user logs in and I will use this number accross the forms
    > I have tried to store it in a Friend variable but once i hide the
    > first form and go to the next form the value goes to 0.
    > If I declare it Static then it is only usefull in one form.
    >
    > What is the best way to do this?[/color]

    I didn't know VB.NET even had a Static modifier - I'll have to look
    that up. I think what you need is Shared and Friend though.

    --
    Jon Skeet - <skeet@pobox.co m>
    Pobox has been discontinued as a separate service, and all existing customers moved to the Fastmail platform.

    If replying to the group, please do not mail me too

    Comment

    • Cor Ligthert

      #3
      Re: Static and Friend

      Webwing,

      What program language are you using because the keyword static have in VBNet
      and C# complete different meanings. (And probably the reason why Shared is
      used for what is in C# Static)

      I would ask it than in the newsgroup.
      language.public .dotnet.languag es.vb or charp

      I hope this helps?

      Cor

      "webwing" <webwing@uol.co m-dot-br.no-spam.invalid>
      [color=blue]
      > Hi,
      >
      > Can someone help please.
      >
      > Basicaly I need to read a registration number across several forms in
      > my project.
      > The user logs in and I will use this number accross the forms
      > I have tried to store it in a Friend variable but once i hide the
      > first form and go to the next form the value goes to 0.
      > If I declare it Static then it is only usefull in one form.
      >
      > What is the best way to do this?
      >
      > Thanks
      >[/color]


      Comment

      • Nick Malik

        #4
        Re: Static and Friend

        Store your registration number in a singleton object. Then you can
        reference it from any of the forms just fine.

        Here's a link to one of Jon's pages that does an excellent job of explaining
        different singleton implementations in C#.


        --- Nick

        "webwing" <webwing@uol.co m-dot-br.no-spam.invalid> wrote in message
        news:415e3617_3 @Usenet.com...[color=blue]
        > Hi,
        >
        > Can someone help please.
        >
        > Basicaly I need to read a registration number across several forms in
        > my project.
        > The user logs in and I will use this number accross the forms
        > I have tried to store it in a Friend variable but once i hide the
        > first form and go to the next form the value goes to 0.
        > If I declare it Static then it is only usefull in one form.
        >
        > What is the best way to do this?
        >
        > Thanks
        >[/color]


        Comment

        Working...