Measurement Studio for VB6

cancel
Showing results for 
Search instead for 
Did you mean: 

Passing CWGPIB to object?

I'm creating VB6 classes for equipment and would like to create a new instance of the CWGPIB control on the form and pass it to the equipment object created from the class.
 
I can declare a variable to be CWGPIB and I can set that variable to the control on the main form, but even passing the resulting object to the class ByVal results in both mirroring each other. For example, if I pass the new object to the class then return, if I change the primary address of the form control then check the primary address of the object's CWGPIB control, they both change to the same value.
 
Any ideas?
0 Kudos
Message 1 of 6
(6,886 Views)
Hi tbihn,
 
I just wanted to clarify the problem you're having. Then we'll see how we can help.
 
It sounds as though you're having a problem with VB treating this as a "Pass by reference" instead of a "pass by value". What is this class that you're passing your value to? Could you perhaps post the small area of code where you pass that value to this external class? It might just be a problem with how this pass is done.
 
Regards,
Matthew S.

LabVIEW Integration Engineer with experience in LabVIEW Real-Time, LabVIEW FPGA, DAQ, Machine Vision, as well as C/C++. CLAD, working on CLD and CLA.
0 Kudos
Message 2 of 6
(6,875 Views)
In my ESA_Spec_An class module, I've attempted the following declarations:
 
private mGPIBControl as CWGPIB
private mGPIBControl as Object
private mGPIBControl as Control
private mGPIBControl as Variant
 
I setup a Public Property Get GPIBControl() As CWGPIB
  Set GPIBControl=mGPIBControl
End Property
 
Public Property Set GPIBConrol(ByVal varGPIBControlToPass as Object/CWGPIB/Variant/Control) <-- tried all those
 
0 Kudos
Message 3 of 6
(6,872 Views)
 
0 Kudos
Message 4 of 6
(6,871 Views)
In my ESA_Spec_An class module, I've attempted the following declarations:
 
private mGPIBControl as CWGPIB
private mGPIBControl as Object
private mGPIBControl as Control
private mGPIBControl as Variant
 
Property Set GPIBControl(ByVal objGPIBControl As CWGPIB)
    Set mGPIBControl = objGPIBControl
End Property

Public Property Get GPIBControl() As CWGPIB
    Set GPIBControl = mGPIBControl
End Property
 
What I would try is to create a new instance of the CWGPIB control that's on one of the forms. The only way I've found to do this so far is:
Load CWGPIB(intNewArrayElement)
E4402B.GPIBControl=CWGPIB(intNewArrayElement)
 
This works for now, but if I make a change to either the new control on the original Windows form or to the CWGPIB object in my ESA object, both change (as if it is referenced ByRef). I'm pretty convinced at this point that I can't do much more in VB, but if you have any suggestions, I'll be happy to listen.
 
Additionally, do you happen to have sample VB6 code on using the Service Request event to identify when an instrument is done processing and ready for the next command?

Message Edited by tbihn on 08-10-2005 07:37 PM

0 Kudos
Message 5 of 6
(6,873 Views)
Hi Tbihn,
 
As far as making any more progress in VB, it might be a bit tough. With objects, VB is always going to pass by reference as far as I know, even if using ByVal. ByVal is used more for passing int values and things like that, not entire objects.
 
One option you have is to copy each attribute from the old object to the new one. That is the only way I can think of doing this. Then the two objects aren't connected at all.
 
I am not aware of any examples for using the Service Request event in VB6. I'll keep an eye out for one for you.
 
Regards,
Matthew S.

LabVIEW Integration Engineer with experience in LabVIEW Real-Time, LabVIEW FPGA, DAQ, Machine Vision, as well as C/C++. CLAD, working on CLD and CLA.
0 Kudos
Message 6 of 6
(6,860 Views)