From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Assigning channel value to variable

Solved!
Go to solution

tl;dr: how to put a particular channel value to a variable?

I have a channel with several numbers which I need to use as variables (they are indexes I need to point band cursor at), all I need is to grab a value from channel and assign it to a variable. I tried it simple, I tried it complicated, ChannelsToArray doesn't seem to help either (got type mismatch).

 

It should be really simple, shouldn't it?

0 Kudos
Message 1 of 3
(2,780 Views)
Solution
Accepted by topic author Adalbertus
dim chO : set chO = Data.Root.ChannelGroups(1).Channels("Time")
dim i : for i = 1 to chO.Size
  dim chVal : chVal = chO.values(i)
  MsgLineDisp chVal
Next

The channel object has a "values" attached to it.

0 Kudos
Message 2 of 3
(2,765 Views)

Well, now I am not sure what I did wrong, cause among others I also tried

 

Dim a
a = cX1Chn.Values(3)
msgbox(a)

I guess something else was wrong and I just falsely took it as bad syntax, anyway thanks.

0 Kudos
Message 3 of 3
(2,760 Views)