From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, 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: 

Record dialog table values into a new channel

I am trying to make a dialog window where a user can enter engine speeds and those values will be transferred to a newly created numeric channel.  This is working to get the table values to an array, but if I try to assign the values to oSpeedChannel I get an error that these values can not be assigned due to the DataType Float 64 of the channel I created.

 

Sub bOK_EventClick(ByRef This) 'Created Event Handler
 
'Sub SaveSpeedData
dim oPara
    
Dim oMyRoot, oMyGroup, oSpeedChannel, i
Set oMyRoot = Data.Root
Set oMyGroup = oMyRoot.ChannelGroups.Add("Lug_Spec")                      'Create new group
Set oSpeedChannel = oMyGroup.Channels.Add("Speed", DataTypeFloat64)  'Create new channel
 
 
  For i = 1 to 5
  
  oSpeedChannel.Values(i) = Table1.Cells(i,1).Value
  
  Next 
 
msgbox oSpeedChannel.Values(2)
'End Sub
 
End Sub
 
Here is what my table looks like
simple_diadem_Table.jpg
 
When I click ok It creates the channel, but errors out at the line for oSpeedChannel.Values(i) = Table1.Cells(i,1).Value
 
simple_diadem_Table_Error.jpg
Is there a different way to read in table values from a dialog window that I can import into a numeric channel?

 

0 Kudos
Message 1 of 2
(550 Views)

Hi OKCat2015,

 

You can use the Val() function of DIAdem to convert the text values into double values.

It would work like this:

oSpeedChannel.Values(i) = Val(Table1.Cells(i,1).Value)

 

 

0 Kudos
Message 2 of 2
(493 Views)