|
I Need to list all the domains and machine in the domains in the network in VB 2.0. does any one has the code
|
|
|
|
|
nitin_ion wrote: in VB 2.0
You've got to be joking right!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Surely he means VB.NET v2. Right?
Steve Jowett
-------------------------
It is offen dangerous to try and see someone else's point of view, without proper training. Douglas Adams (Mostly Harmless)
|
|
|
|
|
I hope... else
Do until "Hell Freezes Over"
Debug.Print("Astonished")
Loop
Kazz
"Users are there to click on things, not think. Let the archs do the damn thinking."
|
|
|
|
|
or
Gosub hades
Hades:
No return
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Sample:
*************************************************
Dim MyCollect as Collection
Set MyCollect = new Collection
Dim Data as Integer
Data = 1
MyCollect.Add Data
Data = 2
MyCollect.Add Data
Data = 3
MyCollect.Add Data
Set MyCollect = Nothing
*************************************************
From the above sample, Collection class object has three item and without remove that item, i just set nothing. The "Set MyCollect = Nothing" statement really remove the item internally or we need to remove externally by iterate item and remove it.
The above sample item is integer data, but my case is that item is an object. So do i need to remove the item (object) from the collection then set nothing?
Sakthivel P.
|
|
|
|
|
It does what it says, sets th whole thing to nothing
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Data is a value type, so you have three ints, not three references to one int. However, there are so many points of confusion here, that your best bet is to buy a book and read it.
Setting a collection to nothing does NOT do anything to the objects in it, it simply gets rid of the object which was maintaining references to the collection.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
That why i'm asking,
Set nothing to collection, it won't free or remove the items of the collection.
|
|
|
|
|
Well, if the collection is the only place a reference to the objects exists, then they are orphaned and will be GC eventually. But, if you have other references to them, then no
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
This collection only the reference to the object. so do i need to remove the item and delete it by external?
|
|
|
|
|
Depends. If they are objects that have a Dispose method, then yes, you should call the Dispose method. If not, what can you do ? you can't delete the objects, this is a GC environment, remember ?
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
|
Let's see exactly what happens with your code...
Dim MyCollect as Collection
Set MyCollect = new Collection
Dim Data as Integer
So far nothing surprising. A reference variable is declared, an object is created and it's reference is stored in the variable, and an integer variable is declared.
Data = 1
MyCollect.Add Data
Here it starts to get interresting. You can only store reference types (i.e. objects) in a collection. As an integer is a value type, it can not be stored in the collection, so what happens is that a new object is created automatically, and the integer value is copied to that object. This is called boxing.
Data = 2
MyCollect.Add Data
Data = 3
MyCollect.Add Data
Here you are saved by the boxing. If Data would have been a reference type, the collection would contain a reference and not a separate object, so you would change the contents of the only one object, and you would have ended up with a collection that contained three references to the same object. The boxing creates separate objects for each value, so you get three separate objects in the collection.
What happens after this statement is where it gets really interresting. As the collection isn't used any more in the code, it's now eligible for garbage collection. The garbage collector can determine that the reference to the collection is never read after this, so the reference is deemed inactive from here on. Eventhough the variable contains a reference to the collection, it doesn't count as the reference is inactive, so there are no longer any active references to the collection.
If a garbage collection would happen at this point in the code, the collection and all the objects that it contains could (and most likely would) be garbage collected.
Set MyCollect = Nothing
This statement actually serves no purpose what so ever in your code. As the garbage collector knows that the reference is alredy inactive at this point, you can put whatever you like in the reference, and it will not change how any objects are garbage collected in any way.
Despite everything, the person most likely to be fooling you next is yourself.
modified on Thursday, June 26, 2008 7:23 AM
|
|
|
|
|
In my actual code that is reference type only. and also collection item used in my actual code (using the collection item i did something), at the end i just set nothing to the collection. is it really remove the collection items and delete the items object.
See the sample
Dim MyCollect as Collection
Set MyCollect = new Collection
Dim Nd as Node 'Node - is a our own class object.
MyCollect.Add Nd 'Add 10/15 object to the collection
'Iterate MyCollect and using it by MyCollect.Item(i)
Set MyCollect = Nothing 'What happend in this line.
Is it really remove the items (10/15) and delete object (Node)?
|
|
|
|
|
Sakthivel P wrote: Set MyCollect = Nothing 'What happend in this line.
Is it really remove the items (10/15) and delete object (Node)?
No, it doesn't.
As I explained, the collection and all that it contains (assuming that there are no other references to it) are up for garbage collection from the moment that it's not used any more. By the time that you set the reference to Nothing, the collection is already unreachable, so setting the reference to Nothing accomplishes nothing at all. The garbage collector already knows that the collection is no longer used.
In some cases it can be useful to clear a reference, that is if the variable is a member in a class, or if you use the variable later in the code. However, clearing a reference doesn't cause anything at all to happen. It can make an object unreachable so that it can be garbage collected, but it never causes a garbage collection to happen.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Guffa wrote: As I explained, the collection and all that it contains (assuming that there are no other references to it) are up for garbage collection from the moment that it's not used any more. By the time that you set the reference to Nothing, the collection is already unreachable, so setting the reference to Nothing accomplishes nothing at all. The garbage collector already knows that the collection is no longer used.
Does that behavior apply in debug mode, or only in final-build mode? I would expect that the compiler should keep variables around even after the last reference, as long as the procedure is in scope, since the variable could be accessed in many ways (including via the Immediate and Watch windows, or even via late modifications to the code).
|
|
|
|
|
supercat9 wrote: Does that behavior apply in debug mode, or only in final-build mode? I would expect that the compiler should keep variables around even after the last reference, as long as the procedure is in scope, since the variable could be accessed in many ways (including via the Immediate and Watch windows, or even via late modifications to the code).
That is correct. In debug mode all variables stay active as long as they are in scope.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Hi Guys,
Need some advice on downtime management...
I am writing an client-server application in a manufacturing environment that needs to do the ffg.
The client will scan a barcode at the begining of a cycle, say the cycle consists of (A,B,C,D)
At 'A', the scan take place and this barcode needs to be vaildated against the server.
If the barcode is valid then i need to drop the barcode in a text file on the local PC for processing(server has a folder watch on this folder)
This barcode cannot be scanned again until it is released at 'D' and then proceeds back to 'A'.
If for some reason the network/server goes down this scanning process must not stop.
For one i wont be able to validate against the server since there is no connection, but i can still create the text file with the barcode in it.
I would think the best solution would be to create the text file on the local pc, let the folder watch pick up files and validate the file for processing(when online).
Could you help me with other ideas, bearing in mind that the barcode when return to point 'A' (physically) can possibly be scanned again when the system is still offline.
Thanks
Anoop
|
|
|
|
|
Is this a real world situation?
Do you expect the server to fail often?
Are you over engineering the business process?
If the server is so unreliable as to fail regularly then you need to address the server issue. Engineering a software solution to a hardware problem is probably not a good idea.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi,
The Server and H/ware is good, operating in a stable environment...
but there are factors to be considered. network issues can occur, damaged cabled etc...
i just wanted to know any other ideas,
thanks for your comment though!
|
|
|
|
|
Sure, I agree, thats called disaster recovery (DR) and every organisation needs to address it. The usual SOP is to have a duplicate system off site where processing can continue with the minimum loss of income. Engineering for work interuptions (not DR) may be also valid but only if the ROI is adequate.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I am using VB6 with MS access
If rs1.State = 1 Then
rs1.Close
End If
my control enter in if statement
but give error while closing
|
|
|
|
|
and error given is
Operation is not allowed in this context
|
|
|
|
|
Hiii
Use Rs1=Nothing
mai be is do same work and not throw any error.
Thanx
Mitesh Khatri
|
|
|
|