Connecting Tech Pros Worldwide Forums | Help | Site Map

Static and Friend

webwing
Guest
 
Posts: n/a
#1: Nov 22 '05
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]
Guest
 
Posts: n/a
#2: Nov 22 '05

re: Static and Friend


webwing <webwing@uol.com-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.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Cor Ligthert
Guest
 
Posts: n/a
#3: Nov 22 '05

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.languages.vb or charp

I hope this helps?

Cor

"webwing" <webwing@uol.com-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]


Nick Malik
Guest
 
Posts: n/a
#4: Nov 22 '05

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#.
http://www.yoda.arachsys.com/csharp/singleton.html

--- Nick

"webwing" <webwing@uol.com-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]


Closed Thread