473,320 Members | 2,003 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.

Is there a way to reinitialize a shared variable?

I have the following class:

public class Test

private shared mObject as Object = New myclass.object
....

Normally, a new instance of that class will share the existing value of
mObject. However, for some special cases, I need it to reinitialize mObject
as if mObject is not declared as shared.
Jan 12 '08 #1
2 1429
Hello Peter

my first guess would be create a shared method were you reinitialize the
variabel when needed

public class Test

private shared mObject as Object = New myclass.object

Public shared sub ReInitObject

mObject=New myclass.object

end sub

......

............
Bether in my opinion would be to avoid static instances at all , as it is
considered as bether coding practice
( or you must have a verry good reasson to use shared , static fields and or
methods
HTH

Michel


"Peter" <Pe***@discussions.microsoft.comschreef in bericht
news:9F**********************************@microsof t.com...
>I have the following class:

public class Test

private shared mObject as Object = New myclass.object
...

Normally, a new instance of that class will share the existing value of
mObject. However, for some special cases, I need it to reinitialize
mObject
as if mObject is not declared as shared.

Jan 12 '08 #2
public class Test
>
private shared mObject as Object = New myclass.object
...
Can you explain a little bit more with this code.

myclass denotes the objects inside the class when it is instanced.
To instance an object you need a type (a class but not itself)

On the other hand why are you doing it so difficult to avoid OOP.
Just use only modules if you are not able to use OOP.

Cor
Jan 12 '08 #3

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

Similar topics

3
by: tom | last post by:
Hello, I'm using the ms data access application blocks. My question is about the fact that everywhere shared methods are used. Does this mean that when more than 1 user at the same time...
1
by: Qingdong Z. | last post by:
Posted in asp.net newsgroup, no answer. Hope some experts can help me here 1. Does class shared variable share same feathers as ASP.NET application variable? 2. If it is, it may work better...
4
by: John Kraft | last post by:
Hi all, My question is more of a phylisophical one here, but I am wondering what the difference is (effectively and performance wise) between using a shared variable/static variable and using a...
3
by: Joe Fallon | last post by:
I have a Shared varibale in a base class and all the Shared methods in the sub-classes use it (and CHANGE it). I thought I was saving myself the "trouble" of Dimming this variable inside each...
10
by: darrel | last post by:
I'm still trying to sort out in my head the differences between public and shared when referring to declaring properties or variables. This is my understanding: shared - akin to a 'global'...
15
by: Rob Nicholson | last post by:
A consequence of the ASP.NET architecture on IIS has just hit home with a big thud. It's to do with shared variables. Consider a module like this: Public Module Functions Public GlobalName As...
8
by: gemel | last post by:
I have been reading sime material in .NET that throws some doubt on my understanding of shared procedures. With regard to object programming I assumed that variables declared within a class were...
4
by: Boni | last post by:
Dear all, how can I initialize shared variable? i.e class A private shared B as boolean end class in C++ I would write in the global scope A::B=true What is the proper way in vb
11
by: eBob.com | last post by:
I have this nasty problem with Shared methods and what I think of as "global storage" - i.e. storage declared outside of any subroutines or functions. In the simple example below this "global"...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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)...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.