473,320 Members | 1,694 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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

Jul 21 '05 #1
3 1147
webwing <we*****@uol.com-dot-br.no-spam.invalid> wrote:
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?


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 - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #2
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" <we*****@uol.com-dot-br.no-spam.invalid>
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

Jul 21 '05 #3
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" <we*****@uol.com-dot-br.no-spam.invalid> wrote in message
news:41********@Usenet.com...
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

Jul 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Marcin Vorbrodt | last post by:
So I have a class Math that looks like this: Math { public: static Real PI(void); }; Real Math::PI(void) { return 4.0 * atan(1.0); }
1
by: Mike - EMAIL IGNORED | last post by:
Are static friend functions allowed? I tried this today with gcc-3.2 without success. The function was not a class member. The friend statement was interpreted as meaning "extern", and this was...
8
by: Ernst Murnleitner | last post by:
Hello Readers, Is there a way that only one class can construct a class A and its inherited classes A2, A3 etc.? I want to construct a class A (and the inherited classes A2, A3 etc.) from a...
15
by: Samee Zahur | last post by:
Question: How do friend functions and static member functions differ in terms of functionality? I mean, neither necessarily needs an object of the class to be created before they are called and...
2
by: asetofsymbols | last post by:
Hi i'm new to c++ i have the class num for big unsigned numbers it seems work ok until now and i want extend the numbers to big-signed and big-float typedef struct{ unsigned len; unsigned* ...
3
by: webwing | last post by:
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...
1
by: Alex Vinokur | last post by:
I want static functions of classes Uam and Bar to be friends of class Foo. There is no problem with Uam::uam(). But class Bar has a member of Foo type: member Bar::m_foo, so one can't put Bar...
8
by: Per Bull Holmen | last post by:
Hey Im new to c++, so bear with me. I'm used to other OO languages, where it is possible to have class-level initialization functions, that initialize the CLASS rather than an instance of it....
1
by: archana15bang | last post by:
hi, i have some queries: 1. can friend functions be virtuals??? and why 2. can friend functions be Static??? and why 3. can virtuals functions be static??? and why
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.