Professional OPC
Development Tools

logos

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.

VB6 - How to read a field an array of string

More
13 Dec 2021 06:43 #10470 by support
Thank you for the code. I do not see anything obviously incorrect there.

Do you have any other UA client that has the capability of reading array ranges?

Regards

Please Log in or Create an account to join the conversation.

More
12 Dec 2021 16:15 #10469 by albi.majun.1960@gmail.com
Hello Support,

thanks for quickest reply.

here my code below, but what I did it' simply a copy and past of the example code on documentation, with some addings to trace better what is going on.

Here a copy & past I did from opc-ua client of the field name "strName" String[501] :
{CODEGA.CSV |A16pr078r2.CSV |bbbb.CSV | | | | | | | | | | | |.......

see attachment if could be helpful

BR
Alberto


On Local Error GoTo errLocal

Screen.MousePointer = vbHourglass

NrLog = FreeFile
LogFile$ = App.Path & "\RicetteKamatech.txt"

Open LogFile$ For Append As #NrLog

OutputText = ""

Dim endpointDescriptor As String

'** my custom setting about the server
endpointDescriptor = "opc.tcp://192.168.1.140:4840"

'or endpointDescriptor = "opcua.demo-this.com:51212/UA/SampleServer/"
'or endpointDescriptor = "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer"

' Instantiate the client object
Dim Client As New EasyUAClient

' Prepare the arguments, indicating that just the elements 2 to 4 should be returned.
Dim indexRangeList As New UAIndexRangeList
Dim indexRange As New UAIndexRange

'*** my custom settings about the array index:
indexRange.Minimum = 0
indexRange.Maximum = 2

indexRangeList.Add indexRange

Dim readArguments1 As New UAReadArguments
readArguments1.endpointDescriptor.UrlString = endpointDescriptor

'*** my custom setting about the nodeId:
readArguments1.NodeDescriptor.NodeId.expandedText = "ns=6;s=::RicOPCUA:recipeOpcUa.par.RecipeName"

Set readArguments1.indexRangeList = indexRangeList

Dim arguments(0) As Variant
Set arguments(0) = readArguments1

' Obtain value.
Dim results() As Variant
results = Client.ReadMultipleValues(arguments)

Dim valueResult As valueResult

Set valueResult = results(0)
If Not valueResult.Succeeded Then
OutputText = OutputText & "*** Failure: " & valueResult.Exception.GetBaseException.Message & vbCrLf
Exit Sub
End If

' Display results
Dim arrayValue() As Long
arrayValue = valueResult.Value

Dim i: For i = LBound(arrayValue) To UBound(arrayValue)
OutputText = OutputText & "arrayValue(" & i & "):" & arrayValue(i) & vbCrLf

'*** my custom setting to trace what is the readout
List1.AddItem "arrayValue(" & i & "):" & arrayValue(i)
Print #NrLog, "arrayValue(" & i & "):" & arrayValue(i)

Next




' Example output:
'arrayValue(0): 180410224
'arrayValue(1): 1919239969
'arrayValue(2): 1700185172

Screen.MousePointer = Default

MsgBox ("Ho finito...")
Close #NrLog

Exit Sub

errLocal:
risp = MsgBox("Errore >>> " & Err.Number & " - " & Err.Description)

Print #NrLog, risp

Close #NrLog
Attachments:

Please Log in or Create an account to join the conversation.

More
12 Dec 2021 13:11 #10468 by support
Hello,
this should work in principle.

Either there is something wrong in your code, or the server is not doing the range extraction properly.
Can you post the relevant piece of code here for review? I know it is based on our example - but I want to see the actual code with the values you are using.

If we do not find anything wrong with the code, you could try running Wireshark and we would analyze the communication - I can help with that.

Also, do you have any other UA client that has the capability of reading array ranges?

In the "worst" case, you could still read the whole array, and perform the range extraction in your code, on the client side. That would be, however. less efficient.

Best regards

Please Log in or Create an account to join the conversation.

More
11 Dec 2021 15:43 #10466 by albi.majun.1960@gmail.com
Hello Support,

I don't know how I have to read the job list already in the PLC of production machine located in the field "strName", because I have to check is
It's a string array , see details in the attachments
"strName_String[501]_field detail.jpg"

I followed also the VB6 example
opclabs.doc-that.com/files/onlinedocs/QuickOpc/Latest/User%2...OPC/Index%20Range%20Lists.html
but unsucessfully, getting the error: *** Failure: Status is not good: BadIndexRangeNoData.

I tried with indexRange.Minimum = 0 and indexRange.Maximum = 10, but also with different values like from min=and max=2

Could you please help me ?
Thnaks+Regards
Alberto
Attachments:

Please Log in or Create an account to join the conversation.

Moderators: support
Time to create page: 0.078 seconds