Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Visual Basic 2005 codes for using ActiveX supplied by Jobin Yvon Spectrometer (iHR320)

I am writing VB2005 codes using calling the ActiveX (COM) components for the spectrometer iHR320.

Usually calling com object resulted in some control in remotely connected iHR320 successfully.

But in my case, some ActiveX call results in OnReceive-like events that must be

caught in a sub-procedure written in main body of form (not in COM object source).

 

JY provided example source codes in VB6. Therefore, as long as using

the VB6 compiler, the iHR320 can be controlled successfully.

 

Previously when I used VB6, writing some subprocedure like

 

Private Sub Objects_Initialize(ByVal e As Long......)

can catch this event fired by ActiveX.

 

Private Sub Objects_Initialize(ByVal e As Long......)

Objects.GetSlitWidth()

.....

End Sub

 

But, it's not possible to catch in VB2005. I tried to add "handles ....." after

the finishing paraenthis of the subproc arguments, but it was in vain.

 

Private Sub  Objects_Initialize(ByVal e As Long......) handles Objects.Initialize

 

 

How should I do to work around. I tried to have questions to Jobin Yvon,

but there is no response.

 

I heard that it corresponds to "OnReceive" eventhanlder in the language of c++.

 

Please share your successful experience about the migration from VBb related to

the connection with ActiveX (COM) objects. I am expecting responses

from those who is familiar with VB2005 as weol as C++.

 

LabView is too expensive for me. It is not option for me.

 

Thanks in advance fro your kind response.

0 Kudos
Message 1 of 4
(3,914 Views)

Why are you using Visual Basic .NET 2005?

The free express version is available for 2015.

 

Can you provide the ActiveX controls that you are using?

 

0 Kudos
Message 2 of 4
(3,899 Views)

Thanks for the reply. I use VB2005 because I write it on WinXP OS so that

I can compare the compilation results between VB6 and VB2005.

Needless to say, the XP machine cannot be connected to the internet.

 

Jobin Yvon provided software development kits consisting of COM objects.

Some of those COM objects raise an event.

I need to write eventhandler statements in a modules,

corresponding to this event rise.

 

JY provided example codes written in VB6 language. In these,

there is surely declaration of the withevent variable like,

 

Public WithEvents mono1 As New ........

 

in the VB module.

 

 

In the case of dot-net language, should I write statements like below?


Sub Mono1_Initialize(ByVal ... As Long, .......) Handles Mono1.Update


When I wrote the above statement, VB2005 IDE generated an error message.

 

I have no idea why this is generated.

 

In my guess, there is some statement in the COM object,

 

RaiseEvent Mono1_Initialize(Byval.... as ., ByVal.. as ...)

 

 

0 Kudos
Message 3 of 4
(3,880 Views)

It worked finally by adding "handles monoObj1.Initialize"

to the relevant subproc.

In addition, upgrade service adds some namespace (or class name)

to the declaration of some variables. Therefore, one should

carefully return the variables to the original forms.

 

Thanks everyone who responded to my post.

0 Kudos
Message 4 of 4
(3,853 Views)