Showing results for 
Search instead for 
Did you mean: 

ValueRangeSet (OLE automation command) - cant make it work

Dear all!

I have been trying to automate the import of data to Diadem (from an external application) first from Visual C++ for quite some time and couldnt bring it to work. So I went back to Visual Basic (.net) for there are some examples in the help section of Diadem. Unfortunately, I cant bring those ones to run either.

Here is my code:

Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim IDIACommand As Object
Dim IDIASheet As Object
Dim lSuccessT

' Init of TOCommand-Interface:

IDIACommand = CreateObject("diadem.tocommand")

' Init of TODataSheet-Interface:

IDIASheet = CreateObject("diadem.todatasheet")

Dim vValueV(1, 1) As Object

ReDim vValueV(100, 100)
Dim i, j

For i = CInt(LBound(vValueV, 1)) To CInt(UBound(vValueV, 1))

For j = CInt(LBound(vValueV, 2)) To CInt(UBound(vValueV, 2))

vValueV(i, j) = 4711.4711



lSuccessT = IDIASheet.ValueRangeSet(1, 1, 3, 1, vValueV)


lSuccessT = IDIASheet.ChnParamsUpdate(1, 4)

End Sub
End Class

I click the button, and then I get a "0" as return in the TextBox (meaning something went wrong with the execution of the OLE command), and also, no data in Diadem has changed. This is more or less directly copied from the example, so I wonder where my mistake is. I also tried to change the type ov vValueV to Double. The strange thing is that I managed to make ValueRangeGet work straight away. But I had so many attempts with ValueRangeSet now, I hope someone else can help me.

Thx for your help!
0 Kudos
Message 1 of 8
Hi diadev

You have to change your script a little bit to make it run.
The problem is that the dimension of the array and the dimension of the data you want to change are not the same. The your array has 101 * 101 values (0-100) but the value in ValueRangeSet is much less.
If you change the line: lSuccessT = IDIASheet.ValueRangeSet(1, 1, 3, 1, vValueV) to

DimX = CInt(UBound(vValueV, 1))-CInt(LBound(vValueV, 1))+1
DimY = CInt(UBound(vValueV, 2))-CInt(LBound(vValueV, 2))+1
lSuccessT = IDIASheet.ValueRangeSet(1, 1, DimX, DimY, vValueV)

Hope this helps

Message 2 of 8
It really was due to the boundaries.. they have to exactly match the parameters you pass into the function.

It is working in VC as well, so I am happy. And grateful.

Thx a lot!!
0 Kudos
Message 3 of 8



I would like to set a complete range of data (array) using OLE command 'ValueRangeSet' instead of setting each single value.

If i try to make this sample run, it does not work properly.


I have a 1D-Array of 'Single Type' Data (Gesamtdaten) and tried the following using VB.net :


oDIAdem = CreateObject("DIAdem.ToDataSheet")



My desired result is to get the 1D-data array into Channelgroup1 Kanal3.



Thanks in advance for any help with this ...

oDIAdem.ValueRangeSet(1, "[1]/Kanal 3", Gesamtdaten.Length, "[1]/Kanal 3", Gesamtdaten)

0 Kudos
Message 4 of 8

Hi Tebe2011,


To my knowledge you can only get and set 2D arrays from/to the Data Portal using OLE (ActiveX).  Have you tried declaring your array as a 2D array where the second dimension is of size 1?


Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 5 of 8



thanks for your answer - the "ValueRangeSet" now shows no error anymore, but it still works strange 😞

After "ValueRangeSet" with the 2D array there is only the first value from this array in Diadem, all other values are not imported, the Diadem channel length is "1"


My 2D array was setup using VB.net : Dim Gesamtdaten(15000, 0) as single


The first array dimension is completely filled with data, but only the value for Gesamtdaten(0, 0) has been transferred to corresponding Diadem channel using :




Laenge = UBound(Gesamtdaten, 1) + 1


oDIAdem.ValueRangeSet(1, "[1]/Kanal 3", Laenge, "[1]/Kanal 3", Gesamtdaten)


What else is going wrong here ?





0 Kudos
Message 6 of 8

Hi Tebe,


Based on the symptom you're reporting, I'd guess that you're trying to write to brand new (empty) channels, right?  In that case all you need to do is explicitly set the channel length to the target value BEFORE you write the data to it, like this (VBScript):

Dim lSuccessT
Dim vValueV(499, 3)
For i = 0 To UBound(vValueV, 1)
  For j = 0 To UBound(vValueV, 2)
    ChnLength(j+1) = UBound(vValueV, 1)+1
    vValueV(i, j) = 4711.4711
Set oDIASheet = CreateObject("DIAdem.TODataSheet")
lSuccessT = oDIASheet.ValueRangeSet(1, 1, 500, 4, vValueV)


Brad Turpin

DIAdem Product Support Engineer

National Instruments

Message 7 of 8



thanks again for your support - it's working now 🙂




0 Kudos
Message 8 of 8