Online Forums
Technical support is provided through Support Forums below. Anybody can view them; you need to Register/Login to our site (see links in upper right corner) in order to Post questions. You do not have to be a licensed user of our product.
Please read Rules for forum posts before reporting your issue or asking a question. OPC Labs team is actively monitoring the forums, and replies as soon as possible. Various technical information can also be found in our Knowledge Base. For your convenience, we have also assembled a Frequently Asked Questions page.
Do not use the Contact page for technical issues.
Help with VBA Code
It is implemented and tested; but there are no plans to release 5.41 yet, as there aren't enough significant changes accumulated yet.
Please Log in or Create an account to join the conversation.
For version 5.41, I want to add a SetState method, which you will be able to use in place of the State property setter, and that should resolve it.
For now, please stick with the old approach. To somewhat easy your pain, I have found that you actually *can* use the "New" keyword (no need for "CreateObject"), you just need to stay away from *declaring* the variable as being early bound. I.e. this does not work:
Dim MonitoredItemArguments1 As New EasyUAMonitoredItemArguments
MonitoredItemArguments1.State = "D2"
Dim MonitoredItemArguments1: Set MonitoredItemArguments1 = New EasyUAMonitoredItemArguments
MonitoredItemArguments1.State = "D2"
Regards
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
I have tested this out after upgrading to v 5.40 but I still get the same error when attempting to assign a value to the state variable after I create the object via the "New" keyword instead of CreateObject.
I altered the UASubscripeToMultiple2 example's SubscribeCommandButton_Click() sub like so:
'Dim MonitoredItemArguments1: Set MonitoredItemArguments1 = CreateObject("OpcLabs.EasyOpc.UA.OperationModel.EasyUAMonitoredItemArguments")
'MonitoredItemArguments1.EndpointDescriptor.UrlString = "http://opcua.demo-this.com:51211/UA/SampleServer"
'MonitoredItemArguments1.NodeDescriptor.NodeId.ExpandedText = "nsu=http://test.org/UA/Data/;i=10845"
'Set MonitoredItemArguments1.MonitoringParameters = MonitoringParameters
'MonitoredItemArguments1.State = "D2"
Dim MonitoredItemArguments1 As EasyUAMonitoredItemArguments
Set MonitoredItemArguments1 = New EasyUAMonitoredItemArguments
MonitoredItemArguments1.EndpointDescriptor.UrlString = "http://opcua.demo-this.com:51211/UA/SampleServer"
MonitoredItemArguments1.NodeDescriptor.NodeId.ExpandedText = "nsu=http://test.org/UA/Data/;i=10845"
Set MonitoredItemArguments1.MonitoringParameters = MonitoringParameters
MonitoredItemArguments1.State = "D2"
Is there some other way I must change it to get it to work properly via the "New" keyword?
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
Do you have an update on this issue? Do you think that the "New" keyword in Excel will work now after your development in VS 2015 with the coming version 5.4, or will it still give the same behavior as before?
Thank you
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
In any case, I will stick with CreateObject for now.
Thanks again.
Please Log in or Create an account to join the conversation.
I know about this - but I do not know the answer; just some hints.
In general, using 'New' in VB6/VBA requires that the object's type library is referenced & present for the compilation. VB can then use early binding on the resulting object, and provide better developer experience etc.
'CreateObject', on the other hand, is completely run-time thing. At the compilation time, VB6/VBA does not know anything about the resulting value, besides the fact that it in OLE automation object. Specifically, it does not know the methods available, their arguments and their types, etc.
Apparently I do not know enough about VB6/VBA, because in the scenario we are discussing, I would think that the results/behavior should be the same. But i know it is not, and I have noticed the same during the development of these examples. That's why I have resorted to the use of 'CreateObject', even though I would normally prefer and use 'New'.
The issue may be related to the fact how .NET generates type libraries from the C# code, and how the COM interop works at run time. I have met some other weird or unexpected things in this area as well.
Interestingly, I am now developing a new version of QuickOPC (5.40+), and have switched to Visual Studio 2015 for its development. And, without having changed anything in the relevant code, some of these COM things started behaving differently - and, as far as I can say, the change was to the better. It is possible that Microsoft has fixed a thing here and there.
Best regards
Please Log in or Create an account to join the conversation.
I am having some trouble building off of one of the VBA Excel examples and I was hoping to get some input on it. This is not specifically related to a problem with the component itself, but more on why certain code works and certain code does not work. I am sure it's more of a lack of knowledge of VBA than anything else, but i was hoping that you could help .
Basically, If I run the code in the UASubscribeToMultiple3.xls file, everything works great.
I have a customer that tried modifying the declaration of the MonitoredItemArguments to use the 'New' keyword as opposed to a call to CreateObject(). It will not allow anything to be assigned to the 'State' variable, and gives an error message, but I cannot figure out why.
So the original code looks like this:
Dim MonitoredItemArguments1: Set MonitoredItemArguments1 = CreateObject("OpcLabs.EasyOpc.UA.OperationModel.EasyUAMonitoredItemArguments")
MonitoredItemArguments1.EndpointDescriptor.UrlString = "http://opcua.demo-this.com:51211/UA/SampleServer"
MonitoredItemArguments1.NodeDescriptor.NodeId.ExpandedText = "nsu=http://test.org/UA/Data/;i=10845"
Set MonitoredItemArguments1.MonitoringParameters = MonitoringParameters
MonitoredItemArguments1.State = "D2"
The slightly altered code looks like this:
Dim MonitoredItemArguments1 As EasyUAMonitoredItemArguments
Set MonitoredItemArguments1 = New EasyUAMonitoredItemArguments
Dim Endpoint As String
Dim Node As String
Dim CellName As String
Endpoint = "http://opcua.demo-this.com:51211/UA/SampleServer"
Node = "nsu=http://test.org/UA/Data/;i=10845"
CellName = "D2"
MonitoredItemArguments1.EndpointDescriptor.UrlString = Endpoint
MonitoredItemArguments1.NodeDescriptor.NodeId.ExpandedText = Node
Set MonitoredItemArguments1.MonitoringParameters = MonitoringParameters
' Below is where it fails. ************************************************
MonitoredItemArguments1.State = CellName ' Gives Runtime error 424: object required
' MonitoredItemArguments1.State ="D2" doesn't work either
' *************************************************************************
The altered code gives back an error on the line that tries to assign a value to the 'State' object that says "Run-time error '424': Object required".
From everything that I can find, it sounds like CreateObject and New are somewhat interchangeable, but that doesn't seem to be the case here.
So basically, I am stumped as to why CreateObject works, but defining it with the 'New' keyword does not. I know that this is more of a VBA question than a specific question about this component, but I was hoping I could get some insight.
Thank you in advance for the help
Please Log in or Create an account to join the conversation.